Skip to content
Snippets Groups Projects
benchmark.go 1.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • package benchmark
    
    import (
    	"fmt"
    	"time"
    )
    
    type Benchmark0 struct {
    	StartTimeRealnet time.Time
    
    	SendChangeRequest     time.Time
    	ReceiveChangeRequest  time.Time
    	ReceiveChangeResponse time.Time
    	ChangeRequestEnd      time.Time
    
    	SendCommitRequest     time.Time
    	ReceiveCommitResponse time.Time
    	CommitEnd             time.Time
    	EndTime               time.Time
    	PropagationDelay      time.Duration
    }
    
    var Current Benchmark0
    
    func (b *Benchmark0) GetDurations() {
    	startToSend := Diff(b.StartTimeRealnet, b.SendChangeRequest).Microseconds()
    	fmt.Println("Start to Send:", startToSend)
    }
    
    func Diff(start, end time.Time) time.Duration {
    	duration := end.Sub(start)
    	return duration
    }
    
    func (b *Benchmark0) Print() {
    	fmt.Println("StartTimeRealnet:")
    	fmt.Println("SendChangeRequest to ReceiveChangeRequest:", b.ReceiveChangeRequest.Sub(b.SendChangeRequest).Microseconds())
    	fmt.Println("SendChangeRequest to ChangeRequestEnd:", b.ChangeRequestEnd.Sub(b.SendChangeRequest).Microseconds())
    	fmt.Println("PropagationDelay:", b.PropagationDelay.Microseconds())
    }