예제 #1
0
func initGet() {
	init := func(st crawler.Store) {
		for i := 0; i < bench_get_size; i++ {
			now := time.Now().UTC()
			st.PutNX(&crawler.URL{
				URL:  *mustParse(fmt.Sprintf("http://example.com/foo/bar/%d", i)),
				Last: now,
			})
		}
	}
	testMem.once.Do(func() {
		testMem.store = crawler.NewMemStore()
		init(testMem.store)
	})
	testBolt.once.Do(func() {
		os.Remove(tmpbolt)
		testBolt.store, _ = boltstore.New(tmpbolt, nil, nil)
		init(testBolt.store)
	})
	testLevel.once.Do(func() {
		os.RemoveAll(tmplevel)
		testLevel.store, _ = levelstore.New(tmplevel, nil, nil)
		init(testLevel.store)
	})
}
예제 #2
0
func BenchmarkMemPut(b *testing.B) {
	ms := crawler.NewMemStore()
	benchPut(b, ms, "MemStore")
}
예제 #3
0
func TestMemStore(t *testing.T) {
	ms := crawler.NewMemStore()
	StoreTest(t, ms)
}