Skip to content

Commit 69edca5

Browse files
authored
Merge pull request #2361 from CortexFoundation/dev
mgas output
2 parents 3b76b70 + d64081d commit 69edca5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/blockchain_insert.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ func (st *insertStats) report(chain []*types.Block, index int, dirty common.Stor
4444
// Fetch the timings for the batch
4545
var (
4646
now = mclock.Now()
47-
elapsed = now.Sub(st.startTime)
47+
elapsed = now.Sub(st.startTime) + 1 // prevent zero division
48+
mgasps = float64(st.usedGas) * 1000 / float64(elapsed)
4849
)
50+
// Update the Mgas per second gauge
51+
chainMgaspsGauge.Update(int64(mgasps))
52+
4953
// If we're at the last block of the batch or report period reached, log
5054
if index == len(chain)-1 || elapsed >= statsReportLimit {
5155
// Count the number of transactions in this segment
@@ -61,6 +65,7 @@ func (st *insertStats) report(chain []*types.Block, index int, dirty common.Stor
6165
"blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
6266
"elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed),
6367
"hps", common.HashSize(float64(end.Difficulty().Int64()) / 13.5),
68+
"mgasps", mgasps,
6469
}
6570
timestamp := time.Unix(int64(end.Time()), 0)
6671
context = append(context, []any{"age", common.PrettyAge(timestamp)}...)

0 commit comments

Comments
 (0)