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() lock.Unlock()
subsetCounter++ subsetCounter++
//time.Sleep(5000 * time.Millisecond) time.Sleep(3000 * time.Millisecond)
} }
// Send a stop message to stop the nodes at the end // Send a stop message to stop the nodes at the end

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

Loading…
Cancel
Save