mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
t3
This commit is contained in:
parent
ffa825809b
commit
523c390082
2 changed files with 11 additions and 14 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"go-ethereum-timing/log2"
|
||||
"math"
|
||||
|
|
@ -208,7 +209,7 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
|
|||
vmerr error
|
||||
)
|
||||
|
||||
startTime:=time.Now()
|
||||
startTime := time.Now()
|
||||
|
||||
if contractCreation {
|
||||
ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value)
|
||||
|
|
@ -218,9 +219,15 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo
|
|||
ret, st.gas, vmerr = evm.Call(sender, st.to(), st.data, st.gas, st.value)
|
||||
}
|
||||
|
||||
endTime:=time.Now()
|
||||
endTime := time.Now()
|
||||
executionTime := endTime.Sub(startTime)
|
||||
log2.Record(st.msg,executionTime)
|
||||
log2.Record(log2.TimingLog{
|
||||
From: st.msg.From().String(),
|
||||
To: st.msg.From().String(),
|
||||
TimeCost: executionTime.Nanoseconds(),
|
||||
DataFirst4ByteHex: hex.EncodeToString(st.msg.Data()[0:4]),
|
||||
Timestamp: time.Now().Unix(),
|
||||
})
|
||||
|
||||
if vmerr != nil {
|
||||
log.Debug("VM returned with error", "err", vmerr)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
package log2
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"go-ethereum-timing/core"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var file *os.File
|
||||
|
|
@ -26,14 +23,7 @@ func InitOutputFile(outputFile string) {
|
|||
log.Fatalln("Fail to create log file for timing.")
|
||||
}
|
||||
}
|
||||
func Record(message core.Message, timeCost time.Duration) error {
|
||||
timingLog := TimingLog{
|
||||
From: message.From().String(),
|
||||
To: message.From().String(),
|
||||
TimeCost: timeCost.Nanoseconds(),
|
||||
DataFirst4ByteHex: hex.EncodeToString(message.Data()[0:4]),
|
||||
Timestamp: time.Now().Unix(),
|
||||
}
|
||||
func Record(timingLog TimingLog) error {
|
||||
b, err := json.Marshal(timingLog)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in a new issue