refactor for better usability
parent
dcfd84cf13
commit
1d9e0f856c
@ -1,46 +1,46 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
//"fmt"
|
||||||
"github.com/BGrewell/go-conversions"
|
//"github.com/BGrewell/go-conversions"
|
||||||
"github.com/BGrewell/go-iperf"
|
//"github.com/BGrewell/go-iperf"
|
||||||
"time"
|
//"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
s := iperf.NewServer()
|
//s := iperf.NewServer()
|
||||||
c := iperf.NewClient("127.0.0.1")
|
//c := iperf.NewClient("127.0.0.1")
|
||||||
includeServer := true
|
//includeServer := true
|
||||||
c.IncludeServer = &includeServer
|
//c.IncludeServer = &includeServer
|
||||||
fmt.Println(s.Id)
|
//fmt.Println(s.Id)
|
||||||
fmt.Println(c.Id)
|
//fmt.Println(c.Id)
|
||||||
|
//
|
||||||
err := s.Start()
|
//err := s.Start()
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
fmt.Println(err)
|
// fmt.Println(err)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
err = c.Start()
|
//err = c.Start()
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
fmt.Println(err)
|
// fmt.Println(err)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
for c.Running {
|
//for c.Running {
|
||||||
time.Sleep(1 * time.Second)
|
// time.Sleep(1 * time.Second)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
fmt.Println("stopping server")
|
//fmt.Println("stopping server")
|
||||||
s.Stop()
|
//s.Stop()
|
||||||
|
//
|
||||||
fmt.Printf("Client exit code: %d\n", *c.ExitCode)
|
//fmt.Printf("Client exit code: %d\n", *c.ExitCode)
|
||||||
fmt.Printf("Server exit code: %d\n", *s.ExitCode)
|
//fmt.Printf("Server exit code: %d\n", *s.ExitCode)
|
||||||
iperf.Cleanup()
|
//iperf.Cleanup()
|
||||||
if c.Report.Error != "" {
|
//if c.Report.Error != "" {
|
||||||
fmt.Println(c.Report.Error)
|
// fmt.Println(c.Report.Error)
|
||||||
} else {
|
//} else {
|
||||||
fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumReceived.BitsPerSecond)))
|
// fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumReceived.BitsPerSecond)))
|
||||||
fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumSent.BitsPerSecond)))
|
// fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report.End.SumSent.BitsPerSecond)))
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue