Skip to content

Commit

Permalink
Merge pull request evmos#18 from ledgerwatch/develop
Browse files Browse the repository at this point in the history
Add profiling flag
  • Loading branch information
AlexeyAkhunov authored Jul 9, 2018
2 parents abca6c7 + 32e98c7 commit 22603cb
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"os"
"runtime/pprof"

"github.com/cosmos/ethermint/core"
"github.com/cosmos/ethermint/state"
Expand All @@ -24,6 +26,8 @@ import (
dbm "github.com/tendermint/tendermint/libs/db"
)

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")

var (
// TODO: Document...
miner501 = ethcommon.HexToAddress("0x35e8e5dC5FBd97c5b421A80B596C030a2Be2A04D")
Expand All @@ -32,7 +36,21 @@ var (

// TODO: Document...
func main() {
stateDB := dbm.NewDB("state", dbm.MemDBBackend, "")
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
fmt.Printf("could not create CPU profile: %v\n", err)
return
}
if err := pprof.StartCPUProfile(f); err != nil {
fmt.Printf("could not start CPU profile: %v\n", err)
return
}
defer pprof.StopCPUProfile()
}

stateDB := dbm.NewDB("state", dbm.MemDBBackend, "")
codeDB := dbm.NewDB("code", dbm.MemDBBackend, "")

ethermintDB, err := state.NewDatabase(stateDB, codeDB)
Expand Down Expand Up @@ -195,10 +213,10 @@ func main() {
}

n++
if (n % 100) == 0 {
if (n % 1000) == 0 {
fmt.Printf("processed %d blocks\n", n)
}
if n >= 1000 {
if n >= 20000 {
break
}
}
Expand Down

0 comments on commit 22603cb

Please sign in to comment.