diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/evm/main.go | 15 | ||||
-rw-r--r-- | cmd/evm/runner.go | 29 | ||||
-rw-r--r-- | cmd/faucet/faucet.go | 2 | ||||
-rw-r--r-- | cmd/geth/accountcmd.go | 45 |
4 files changed, 75 insertions, 16 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 5f85f484e..e85d31d03 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -35,6 +35,18 @@ var ( Name: "debug", Usage: "output full trace logs", } + MemProfileFlag = cli.StringFlag{ + Name: "memprofile", + Usage: "creates a memory profile at the given path", + } + CPUProfileFlag = cli.StringFlag{ + Name: "cpuprofile", + Usage: "creates a CPU profile at the given path", + } + StatDumpFlag = cli.BoolFlag{ + Name: "statdump", + Usage: "displays stack and heap memory information", + } CodeFlag = cli.StringFlag{ Name: "code", Usage: "EVM code", @@ -93,6 +105,9 @@ func init() { DumpFlag, InputFlag, DisableGasMeteringFlag, + MemProfileFlag, + CPUProfileFlag, + StatDumpFlag, } app.Commands = []cli.Command{ compileCommand, diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 6ef9230f4..22538d7b1 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "runtime/pprof" "time" goruntime "runtime" @@ -108,6 +109,19 @@ func runCmd(ctx *cli.Context) error { }, } + if cpuProfilePath := ctx.GlobalString(CPUProfileFlag.Name); cpuProfilePath != "" { + f, err := os.Create(cpuProfilePath) + if err != nil { + fmt.Println("could not create CPU profile: ", err) + os.Exit(1) + } + if err := pprof.StartCPUProfile(f); err != nil { + fmt.Println("could not start CPU profile: ", err) + os.Exit(1) + } + defer pprof.StopCPUProfile() + } + tstart := time.Now() if ctx.GlobalBool(CreateFlag.Name) { input := append(code, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name))...) @@ -125,12 +139,27 @@ func runCmd(ctx *cli.Context) error { fmt.Println(string(statedb.Dump())) } + if memProfilePath := ctx.GlobalString(MemProfileFlag.Name); memProfilePath != "" { + f, err := os.Create(memProfilePath) + if err != nil { + fmt.Println("could not create memory profile: ", err) + os.Exit(1) + } + if err := pprof.WriteHeapProfile(f); err != nil { + fmt.Println("could not write memory profile: ", err) + os.Exit(1) + } + f.Close() + } + if ctx.GlobalBool(DebugFlag.Name) { fmt.Fprintln(os.Stderr, "#### TRACE ####") vm.WriteTrace(os.Stderr, logger.StructLogs()) fmt.Fprintln(os.Stderr, "#### LOGS ####") vm.WriteLogs(os.Stderr, statedb.Logs()) + } + if ctx.GlobalBool(StatDumpFlag.Name) { var mem goruntime.MemStats goruntime.ReadMemStats(&mem) fmt.Fprintf(os.Stderr, `evm execution time: %v diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index f672433ee..c06c4365b 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -102,7 +102,7 @@ func main() { if amount == 1 { amounts[i] = strings.TrimSuffix(amounts[i], "s") } - // Calcualte the period for th enext tier and format it + // Calculate the period for the next tier and format it period := *minutesFlag * int(math.Pow(3, float64(i))) periods[i] = fmt.Sprintf("%d mins", period) if period%60 == 0 { diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 1a3c63da9..5c756e66d 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -31,25 +31,40 @@ import ( var ( walletCommand = cli.Command{ - Name: "wallet", - Usage: "Import Ethereum presale wallets", - Action: utils.MigrateFlags(importWallet), - Category: "ACCOUNT COMMANDS", - Flags: []cli.Flag{ - utils.DataDirFlag, - utils.KeyStoreDirFlag, - utils.PasswordFileFlag, - utils.LightKDFFlag, - }, + Name: "wallet", + Usage: "Manage Ethereum presale wallets", + ArgsUsage: "", + Category: "ACCOUNT COMMANDS", Description: ` - geth wallet [options] /path/to/my/presale.wallet + geth wallet import /path/to/my/presale.wallet + +will prompt for your password and imports your ether presale account. +It can be used non-interactively with the --password option taking a +passwordfile as argument containing the wallet password in plaintext.`, + Subcommands: []cli.Command{ + { - will prompt for your password and imports your ether presale account. - It can be used non-interactively with the --password option taking a - passwordfile as argument containing the wallet password in plaintext. + Name: "import", + Usage: "Import Ethereum presale wallet", + ArgsUsage: "<keyFile>", + Action: utils.MigrateFlags(importWallet), + Category: "ACCOUNT COMMANDS", + Flags: []cli.Flag{ + utils.DataDirFlag, + utils.KeyStoreDirFlag, + utils.PasswordFileFlag, + utils.LightKDFFlag, + }, + Description: ` + geth wallet [options] /path/to/my/presale.wallet - `, +will prompt for your password and imports your ether presale account. +It can be used non-interactively with the --password option taking a +passwordfile as argument containing the wallet password in plaintext.`, + }, + }, } + accountCommand = cli.Command{ Name: "account", Usage: "Manage accounts", |