feat: refactor benchmark
This commit is contained in:
parent
1697e354f4
commit
79771bebb4
|
@ -44,7 +44,7 @@ func doRequest(wg *sync.WaitGroup, host, employeeID string, errChan chan error)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Benchmark() error {
|
func Benchmark(totalRequests int) error {
|
||||||
cr := crono.New()
|
cr := crono.New()
|
||||||
defer cr.Table()
|
defer cr.Table()
|
||||||
host := "http://127.0.0.1:45654"
|
host := "http://127.0.0.1:45654"
|
||||||
|
@ -52,7 +52,6 @@ func Benchmark() error {
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
totalRequests := 5000
|
|
||||||
go func(errChan chan error) {
|
go func(errChan chan error) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
go_benchmark "gitea.urkob.com/urko/ess-etl-go/benchmark/go"
|
// go_benchmark "gitea.urkob.com/urko/ess-etl-go/benchmark/go"
|
||||||
|
nest_benchmark "gitea.urkob.com/urko/ess-etl-go/benchmark/nest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -21,11 +22,12 @@ func main() {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
|
||||||
if err := go_benchmark.Benchmark(); err != nil {
|
totalRequests := 5000
|
||||||
log.Fatalln("go_benchmark.Benchmark", err)
|
// if err := go_benchmark.Benchmark(totalRequests); err != nil {
|
||||||
}
|
// log.Fatalln("go_benchmark.Benchmark", err)
|
||||||
|
|
||||||
// if err := nest_benchmark.Benchmark(); err != nil {
|
|
||||||
// log.Fatalln("nest_benchmark.Benchmark", err)
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if err := nest_benchmark.Benchmark(totalRequests); err != nil {
|
||||||
|
log.Fatalln("nest_benchmark.Benchmark", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ func doRequest(wg *sync.WaitGroup, host string, employeeID int, errChan chan err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Benchmark() error {
|
func Benchmark(totalRequests int) error {
|
||||||
cr := crono.New()
|
cr := crono.New()
|
||||||
defer cr.Table()
|
defer cr.Table()
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ func Benchmark() error {
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
totalRequests := 5000
|
|
||||||
go func(errChan chan error) {
|
go func(errChan chan error) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
Loading…
Reference in New Issue