2022-05-16 21:32:16 +02:00
|
|
|
package lists
|
|
|
|
|
|
|
|
import (
|
2023-10-07 22:21:40 +02:00
|
|
|
"context"
|
2022-05-16 21:32:16 +02:00
|
|
|
"testing"
|
2023-04-17 18:21:56 +02:00
|
|
|
|
|
|
|
"github.com/0xERR0R/blocky/config"
|
2022-05-16 21:32:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkRefresh(b *testing.B) {
|
2023-03-07 01:32:41 +01:00
|
|
|
file1, _ := createTestListFile(b.TempDir(), 100000)
|
|
|
|
file2, _ := createTestListFile(b.TempDir(), 150000)
|
|
|
|
file3, _ := createTestListFile(b.TempDir(), 130000)
|
2023-04-17 18:21:56 +02:00
|
|
|
lists := map[string][]config.BytesSource{
|
|
|
|
"gr1": config.NewBytesSources(file1, file2, file3),
|
2022-05-16 21:32:16 +02:00
|
|
|
}
|
|
|
|
|
2023-12-20 21:38:33 +01:00
|
|
|
cfg := config.SourceLoading{
|
2023-04-17 18:21:56 +02:00
|
|
|
Concurrency: 5,
|
|
|
|
RefreshPeriod: config.Duration(-1),
|
|
|
|
}
|
2023-12-20 21:38:33 +01:00
|
|
|
downloader := NewDownloader(config.Downloader{}, nil)
|
2024-04-08 19:09:51 +02:00
|
|
|
cache, _ := NewListCache(context.Background(), ListCacheTypeDenylist, cfg, lists, downloader)
|
2022-05-16 21:32:16 +02:00
|
|
|
|
|
|
|
b.ReportAllocs()
|
|
|
|
|
|
|
|
for n := 0; n < b.N; n++ {
|
2023-09-09 19:30:55 +02:00
|
|
|
_ = cache.Refresh()
|
2022-05-16 21:32:16 +02:00
|
|
|
}
|
|
|
|
}
|