Ejemplo n.º 1
0
func disableLogging() {
	testutil.SetLogLevel(logging.ERROR, "indexes")
	testutil.SetLogLevel(logging.ERROR, "ledger")
	testutil.SetLogLevel(logging.INFO, "state")
	testutil.SetLogLevel(logging.ERROR, "statemgmt")
	testutil.SetLogLevel(logging.INFO, "buckettree")
	testutil.SetLogLevel(logging.ERROR, "db")
}
Ejemplo n.º 2
0
func BenchmarkStateHash(b *testing.B) {
	b.StopTimer()
	b.Logf("testParams:%q", testParams)
	flags := flag.NewFlagSet("testParams", flag.ExitOnError)
	numBuckets := flags.Int("NumBuckets", 10009, "Number of buckets")
	maxGroupingAtEachLevel := flags.Int("MaxGroupingAtEachLevel", 10, "max grouping at each level")
	chaincodeIDPrefix := flags.String("ChaincodeIDPrefix", "cID", "The chaincodeID used in the generated workload will be  ChaincodeIDPrefix_1, ChaincodeIDPrefix_2, and so on")
	numChaincodes := flags.Int("NumChaincodes", 1, "Number of chaincodes to assume")
	maxKeySuffix := flags.Int("MaxKeySuffix", 1, "the keys are appended with _1, _2,.. upto MaxKeySuffix")
	numKeysToInsert := flags.Int("NumKeysToInsert", 1, "how many keys to insert in a single batch")
	kvSize := flags.Int("KVSize", 1000, "size of the value")
	debugMsgsOn := flags.Bool("DebugOn", false, "Trun on/off debug messages during benchmarking")
	flags.Parse(testParams)

	b.Logf(`Running test with params:
		numbBuckets=%d, maxGroupingAtEachLevel=%d, chaincodeIDPrefix=%s, numChaincodes=%d, maxKeySuffix=%d, numKeysToInsert=%d, valueSize=%d, debugMsgs=%t`,
		*numBuckets, *maxGroupingAtEachLevel, *chaincodeIDPrefix, *numChaincodes, *maxKeySuffix, *numKeysToInsert, *kvSize, *debugMsgsOn)

	if !*debugMsgsOn {
		testutil.SetLogLevel(logging.ERROR, "statemgmt")
		testutil.SetLogLevel(logging.ERROR, "buckettree")
		testutil.SetLogLevel(logging.ERROR, "db")
	}

	stateImplTestWrapper := newStateImplTestWrapperWithCustomConfig(b, *numBuckets, *maxGroupingAtEachLevel)
	for i := 0; i < b.N; i++ {
		b.StopTimer()
		delta := statemgmt.ConstructRandomStateDelta(b, *chaincodeIDPrefix, *numChaincodes, *maxKeySuffix, *numKeysToInsert, *kvSize)
		b.StartTimer()
		stateImplTestWrapper.prepareWorkingSet(delta)
		stateImplTestWrapper.computeCryptoHash()
		if i == b.N-1 {
			stateImplTestWrapper.persistChangesAndResetInMemoryChanges()
			testDBWrapper.CloseDB(b)
		}
	}
}