Add stats test and print observation count
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
1bc9fbca20
commit
a6417dc24b
@ -434,7 +434,7 @@ var importAnalyzeCmd = &cli.Command{
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
s := charges[k]
|
||||
fmt.Printf("%s: incr by %f (%f)\n", k, s.mean, math.Sqrt(s.variance()))
|
||||
fmt.Printf("%s: incr by %f (stddev: %f, count: %f)\n", k, s.mean, math.Sqrt(s.variance()), s.count)
|
||||
}
|
||||
|
||||
sort.Slice(invocs, func(i, j int) bool {
|
||||
|
26
cmd/lotus-bench/stats_test.go
Normal file
26
cmd/lotus-bench/stats_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"math"
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStats(t *testing.T) {
|
||||
N := 16
|
||||
ss := make([]*stats, N)
|
||||
for i := 0; i < N; i++ {
|
||||
ss[i] = &stats{}
|
||||
maxJ := rand.Intn(1000)
|
||||
for j := 0; j < maxJ; j++ {
|
||||
ss[i].AddPoint(rand.NormFloat64()*5 + 500)
|
||||
ss[i].AddPoint(rand.NormFloat64()*5 + 1000)
|
||||
}
|
||||
t.Logf("mean: %f, stddev: %f, count %f", ss[i].mean, math.Sqrt(ss[i].variance()), ss[i].count)
|
||||
}
|
||||
out := &stats{}
|
||||
for i := 0; i < N; i++ {
|
||||
out.Combine(ss[i])
|
||||
t.Logf("combine: mean: %f, stddev: %f", out.mean, math.Sqrt(out.variance()))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user