diff --git a/sim_test.go b/sim_test.go index 5ea553e3e2a4..54b4e10340c9 100644 --- a/sim_test.go +++ b/sim_test.go @@ -36,6 +36,7 @@ func init() { flag.StringVar(&exportParamsPath, "ExportParamsPath", "", "custom file path to save the exported params JSON") flag.IntVar(&exportParamsHeight, "ExportParamsHeight", 0, "height to which export the randomly generated params") flag.StringVar(&exportStatePath, "ExportStatePath", "", "custom file path to save the exported app state JSON") + flag.StringVar(&exportStatsPath, "ExportStatsPath", "", "custom file path to save the exported simulation statistics JSON") flag.Int64Var(&seed, "Seed", 42, "simulation random seed") flag.IntVar(&numBlocks, "NumBlocks", 500, "number of blocks") flag.IntVar(&blockSize, "BlockSize", 200, "operations per block") @@ -52,7 +53,7 @@ func init() { // helper function for populating input for SimulateFromSeed func getSimulateFromSeedInput(tb testing.TB, w io.Writer, app *SimApp) ( testing.TB, io.Writer, *baseapp.BaseApp, simulation.AppStateFn, int64, - simulation.WeightedOperations, sdk.Invariants, int, int, int, + simulation.WeightedOperations, sdk.Invariants, int, int, int, string, bool, bool, bool, bool, bool, map[string]bool) { exportParams := exportParamsPath != "" @@ -60,7 +61,7 @@ func getSimulateFromSeedInput(tb testing.TB, w io.Writer, app *SimApp) ( return tb, w, app.BaseApp, appStateFn, seed, testAndRunTxs(app), invariants(app), numBlocks, exportParamsHeight, blockSize, - exportParams, commit, lean, onOperation, allInvariants, app.ModuleAccountAddrs() + exportStatsPath, exportParams, commit, lean, onOperation, allInvariants, app.ModuleAccountAddrs() } func appStateFn( @@ -412,7 +413,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { } if commit { - fmt.Println("GoLevelDB Stats") + fmt.Println("\nGoLevelDB Stats") fmt.Println(db.Stats()["leveldb.stats"]) fmt.Println("GoLevelDB cached block size", db.Stats()["leveldb.cachedblock"]) } @@ -471,7 +472,7 @@ func TestFullAppSimulation(t *testing.T) { if commit { // for memdb: // fmt.Println("Database Size", db.Stats()["database.size"]) - fmt.Println("GoLevelDB Stats") + fmt.Println("\nGoLevelDB Stats") fmt.Println(db.Stats()["leveldb.stats"]) fmt.Println("GoLevelDB cached block size", db.Stats()["leveldb.cachedblock"]) } @@ -528,7 +529,7 @@ func TestAppImportExport(t *testing.T) { if commit { // for memdb: // fmt.Println("Database Size", db.Stats()["database.size"]) - fmt.Println("GoLevelDB Stats") + fmt.Println("\nGoLevelDB Stats") fmt.Println(db.Stats()["leveldb.stats"]) fmt.Println("GoLevelDB cached block size", db.Stats()["leveldb.cachedblock"]) } @@ -644,7 +645,7 @@ func TestAppSimulationAfterImport(t *testing.T) { if commit { // for memdb: // fmt.Println("Database Size", db.Stats()["database.size"]) - fmt.Println("GoLevelDB Stats") + fmt.Println("\nGoLevelDB Stats") fmt.Println(db.Stats()["leveldb.stats"]) fmt.Println("GoLevelDB cached block size", db.Stats()["leveldb.cachedblock"]) } @@ -705,7 +706,7 @@ func TestAppStateDeterminism(t *testing.T) { simulation.SimulateFromSeed( t, os.Stdout, app.BaseApp, appStateFn, seed, testAndRunTxs(app), []sdk.Invariant{}, - 50, 100, 0, + 50, 100, 0, "", false, true, false, false, false, app.ModuleAccountAddrs(), ) appHash := app.LastCommitID().Hash @@ -734,7 +735,7 @@ func BenchmarkInvariants(b *testing.B) { _, params, simErr := simulation.SimulateFromSeed( b, ioutil.Discard, app.BaseApp, appStateFn, seed, testAndRunTxs(app), []sdk.Invariant{}, numBlocks, exportParamsHeight, blockSize, - exportParams, commit, lean, onOperation, false, app.ModuleAccountAddrs(), + exportStatsPath, exportParams, commit, lean, onOperation, false, app.ModuleAccountAddrs(), ) // export state and params before the simulation error is checked diff --git a/utils.go b/utils.go index b4271b90f514..a97e0558d77b 100644 --- a/utils.go +++ b/utils.go @@ -43,6 +43,7 @@ var ( exportParamsPath string exportParamsHeight int exportStatePath string + exportStatsPath string seed int64 numBlocks int blockSize int