Ejemplo n.º 1
0
func BenchmarkBlamer(b *testing.B) {
	tileBuilder := mocks.GetTileBuilderFromEnv(b)

	// Get a tile to make sure it's cached.
	tileBuilder.GetTile()
	b.ResetTimer()
	testBlamerWithLiveData(b, tileBuilder)
}
Ejemplo n.º 2
0
func BenchmarkStatusWatcher(b *testing.B) {
	// Get the TEST_TILE environment variable that points to the
	// tile to read.
	tileBuilder := mocks.GetTileBuilderFromEnv(b)

	storages := &storage.Storage{
		MasterTileBuilder: tileBuilder,
	}

	// Load the tile into memory and reset the timer to avoid measuring
	// disk load time.
	_, err := storages.GetLastTileTrimmed(true)
	assert.Nil(b, err)
	b.ResetTimer()
	testStatusWatcher(b, tileBuilder)
}
Ejemplo n.º 3
0
func BenchmarkHistory(b *testing.B) {
	assert.Nil(b, os.MkdirAll(TEST_DATA_DIR, 0755))
	defer testutils.RemoveAll(b, TEST_DATA_DIR)

	digestStore, err := digeststore.New(TEST_DATA_DIR)
	assert.Nil(b, err)

	tileBuilder := mocks.GetTileBuilderFromEnv(b)
	storages := &storage.Storage{
		MasterTileBuilder: tileBuilder,
		DigestStore:       digestStore,
		EventBus:          eventbus.New(nil),
	}

	tile := tileBuilder.GetTile()
	assert.Nil(b, Init(storages, 0))

	// Gather the runtimes of the testname/digest lookup.
	runtimes := make([]int64, 0, 1000000)
	timeIt := func(testName, digest string) (bool, error) {
		startTime := time.Now().UnixNano()
		_, found, err := digestStore.Get(testName, digest)
		runtimes = append(runtimes, (time.Now().UnixNano()-startTime)/1000)
		return found, err
	}

	b.ResetTimer()
	tileLen := tile.LastCommitIndex() + 1
	for _, trace := range tile.Traces {
		testName := trace.Params()[types.PRIMARY_KEY_FIELD]
		gTrace := trace.(*types.GoldenTrace)
		for _, digest := range gTrace.Values[:tileLen] {
			if digest != types.MISSING_DIGEST {
				found, err := timeIt(testName, digest)
				assert.Nil(b, err)
				assert.True(b, found)
			}
		}
	}

	var avg int64 = 0
	for _, val := range runtimes {
		avg += val
	}
	glog.Infof("Average lookup time: %.3fus", float64(avg)/float64(len(runtimes)))
	glog.Infof("Number of lookups  : %d", len(runtimes))
}