Skip to content

Commit

Permalink
fix int64 to float64 overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkiller committed Feb 18, 2018
1 parent b1e3509 commit e184f70
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,38 @@ a golang performence testing platform

## demo client
```go
perfm := perfm.New(perfm.WithBinsNumber(15), perfm.WithParallel(5), perfm.WithDuration(10))
j := &job{}
j.url = "http://www.baidu.com"
perfm.Regist(j)
type job struct {
// job private data
url string
}

perfm.Start()
perfm.Wait()
// Copy will called in parallel
func (j *job) Copy() perfm.Job {
jc := *j
return &jc
}

func (j *job) Pre() {
// do pre job
}
func (j *job) Do() error {
// do benchmark job
_, err := http.Get(j.url)
return err
}
func (j *job) After() {
// do clean job
}

// start perfm

perfm := perfm.New(perfm.WithBinsNumber(15), perfm.WithParallel(5), perfm.WithDuration(10))
j := &job{}
j.url = "http://www.baidu.com"
perfm.Regist(j)

perfm.Start()
perfm.Wait()

```
![test demo](./demo/screen.png)
Expand Down
2 changes: 1 addition & 1 deletion demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type job struct {
// job data here
// job private data
url string
}

Expand Down
Binary file modified demo/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions perfm.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ func (p *perfmonitor) Start() {
// Wait for the benchmark task done and caculate the result
func (p *perfmonitor) Wait() {
p.wg.Wait()
var sum2, i, d, max, min int64
var sum2, i, d, max, min float64
min = 0x7fffffffffffffff
for i = 0; i < p.Total; i++ {
d = <-p.buffer
for i = 0; int64(i) < p.Total; i++ {
d = float64(<-p.buffer)
p.histogram.Add(float64(d))
p.Sum += float64(d)
sum2 += d * d
Expand Down

0 comments on commit e184f70

Please sign in to comment.