internal/importer/main_test.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | package importer import ( "context" "testing" "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/index" "go.alanpearce.eu/x/log" ) var cfg = config.DefaultConfig func BenchmarkImporterLowMemory(b *testing.B) { tmp := b.TempDir() logger := log.Configure(false) _, write, _, err := index.OpenOrCreate(tmp, false, &index.Options{ LowMemory: true, BatchSize: cfg.Importer.BatchSize, Logger: logger.Named("index"), }) if err != nil { b.Fatal(err) } imp, err := New(&cfg, &Options{ Logger: logger.Named("importer"), LowMemory: true, WriteIndex: write, }) if err != nil { b.Fatal(err) } err = imp.Start( context.Background(), false, &[]string{"nixpkgs"}, ) if err != nil { b.Fatal(err) } } |