Example #1
0
// Testing EnumerateBlobMeta because that's one of the few non-corpus index reading ops we still actually use.
func BenchmarkEnumerateBlobMetaSQLite(b *testing.B) {
	if *flagBenchDir == "" {
		b.Skip("Enumerating benchmark needs -benchDir")
	}
	dbfile := filepath.Join(*flagBenchDir, "sqlite.db")
	enumerateMeta(b, dbfile, func(dbfile string) (sorted.KeyValue, error) {
		return sqlite.NewStorage(dbfile)
	})
}
Example #2
0
func BenchmarkInterruptSQLite(b *testing.B) {
	if *flagBenchDir == "" {
		b.Skip("Interrupt benchmark needs -benchDir")
	}
	dbfile := filepath.Join(*flagBenchDir, "sqlite.db")

	benchmarkKillReindex(b, 15, dbfile, func(dbfile string) (sorted.KeyValue, error) {
		return sqlite.NewStorage(dbfile)
	})
}
Example #3
0
func TestChildIndexer(t *testing.T) {
	if os.Getenv("TEST_BE_CHILD") != "1" {
		t.Skip("not a real test; used as a child process by the benchmarks")
	}
	dbfile := os.Getenv("TEST_BE_CHILD_DBFILE")
	if dbfile == "" {
		log.Fatal("empty TEST_BE_CHILD_DBFILE")
	}
	if err := os.RemoveAll(dbfile); err != nil {
		log.Fatal(err)
	}
	var kv sorted.KeyValue
	var err error
	switch {
	case strings.HasSuffix(dbfile, "leveldb.db"):
		kv, err = leveldb.NewStorage(dbfile)
	case strings.HasSuffix(dbfile, "kvfile.db"):
		kv, err = kvfile.NewStorage(dbfile)
	case strings.HasSuffix(dbfile, "sqlite.db"):
		kv, err = sqlite.NewStorage(dbfile)
	default:
		log.Fatalf("unknown sorted provider for %v", dbfile)
	}
	if err != nil {
		log.Fatal(err)
	}
	bs, err := localdisk.New(filepath.Join(filepath.Dir(dbfile), "bs"))
	if err != nil {
		log.Fatal(err)
	}
	idx, err := index.New(kv)
	if err != nil {
		log.Fatal(err)
	}
	idx.InitBlobSource(bs)
	defer func() {
		if err := idx.Close(); err != nil {
			log.Fatal(err)
		}
	}()
	if err := idx.Reindex(); err != nil {
		log.Fatal(err)
	}
}
Example #4
0
func BenchmarkPopulateSQLite(b *testing.B) {
	benchmarkPopulate(b, "sqlite.db", func(dbfile string) (sorted.KeyValue, error) {
		return sqlite.NewStorage(dbfile)
	})
}