Add timer log on p2p broadcast

pull/69/head
Rongjian Lan 6 years ago
parent 72db858956
commit 22ef82be6a
  1. 2
      client/txgen/main.go
  2. 7
      p2p/peer.go

@ -371,7 +371,7 @@ func main() {
lock.Unlock()
subsetCounter++
//time.Sleep(5000 * time.Millisecond)
time.Sleep(3000 * time.Millisecond)
}
// Send a stop message to stop the nodes at the end

@ -3,12 +3,14 @@ package p2p
import (
"bytes"
"encoding/binary"
"log"
"net"
"runtime"
"strings"
"sync"
"time"
"github.com/simple-rules/harmony-benchmark/attack"
"github.com/simple-rules/harmony-benchmark/log"
"github.com/dedis/kyber"
)
@ -38,6 +40,8 @@ func BroadcastMessage(peers []Peer, msg []byte) {
var wg sync.WaitGroup
wg.Add(len(peers))
log.Info("Start Broadcasting", "gomaxprocs", runtime.GOMAXPROCS(0))
start := time.Now()
for _, peer := range peers {
peerCopy := peer
go func() {
@ -46,6 +50,7 @@ func BroadcastMessage(peers []Peer, msg []byte) {
}()
}
wg.Wait()
log.Info("Broadcasting Down", "time spent", time.Now().Sub(start).Seconds())
}
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]

Loading…
Cancel
Save