log mem usage.

pull/37/head
Richard Liu 6 years ago
parent 635171bf76
commit cbedf08a6c
  1. 14
      benchmark.go
  2. 7
      consensus/consensus_leader.go

@ -9,8 +9,10 @@ import (
"harmony-benchmark/log"
"harmony-benchmark/node"
"harmony-benchmark/p2p"
"harmony-benchmark/utils"
"math/rand"
"os"
"runtime"
"strings"
"time"
)
@ -90,6 +92,16 @@ func attackDetermination(attackedMode int) bool {
return false
}
func logMemUsage(consensus *consensus.Consensus) {
for {
var m runtime.MemStats
runtime.ReadMemStats(&m)
log.Info("Mem Report", "Alloc", utils.BToMb(m.Alloc), "TotalAlloc", utils.BToMb(m.TotalAlloc),
"Sys", utils.BToMb(m.Sys), "NumGC", m.NumGC, "consensus", consensus)
time.Sleep(10 * time.Second)
}
}
func main() {
ip := flag.String("ip", "127.0.0.1", "IP of the node")
port := flag.String("port", "9000", "port of the node.")
@ -120,6 +132,8 @@ func main() {
consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader)
go logMemUsage(&consensus)
node := node.NewNode(&consensus)
// Set logger to attack model.
attack.GetInstance().SetLogger(consensus.Log)

@ -7,8 +7,6 @@ import (
"encoding/gob"
"harmony-benchmark/blockchain"
"harmony-benchmark/p2p"
"harmony-benchmark/utils"
"runtime"
"strings"
"time"
)
@ -336,11 +334,6 @@ func (consensus *Consensus) processResponseMessage(payload []byte) {
"timeElapsed", timeElapsed,
"TPS", float64(numOfTxs)/timeElapsed.Seconds())
var m runtime.MemStats
runtime.ReadMemStats(&m)
consensus.Log.Info("Mem Report", "Alloc", utils.BToMb(m.Alloc), "TotalAlloc", utils.BToMb(m.TotalAlloc),
"Sys", utils.BToMb(m.Sys), "NumGC", m.NumGC)
// Send signal to Node so the new block can be added and new round of consensus can be triggered
consensus.ReadySignal <- 1
}

Loading…
Cancel
Save