Commit 99f887ce authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop extra cache heating run in benchmark; use b.N as stat count instead.

parent 6db54109
......@@ -56,7 +56,7 @@ func BulkStat(parallelism int, files []string) float64 {
return avg
}
func AnalyzeBenchmarkRuns(times []float64) {
func AnalyzeBenchmarkRuns(label string, times []float64) {
sorted := times
sort.Float64s(sorted)
......@@ -80,22 +80,18 @@ func AnalyzeBenchmarkRuns(times []float64) {
perc10 := sorted[int(n*0.1)]
fmt.Printf(
"%d samples\n"+
"avg %.3f ms 2sigma %.3f "+
"%s: %d samples\n"+
"avg %.3fms 2sigma %.3fms "+
"median %.3fms\n"+
"10%%tile %.3fms, 90%%tile %.3fms\n",
label,
len(times), avg, 2*stddev, median, perc10, perc90)
}
func RunBulkStat(runs int, threads int, sleepTime time.Duration, files []string) (results []float64) {
runs++
for j := 0; j < runs; j++ {
result := BulkStat(threads, files)
if j > 0 {
results = append(results, result)
} else {
fmt.Println("Ignoring first run to preheat caches.")
}
if j < runs-1 {
fmt.Printf("Sleeping %.2f seconds\n", sleepTime)
......
......@@ -183,37 +183,29 @@ func BenchmarkGoFuseThreadedStat(b *testing.B) {
files[i] = filepath.Join(wd, l)
}
log.Println("N = ", b.N)
threads := runtime.GOMAXPROCS(0)
results := TestingBOnePass(b, threads, time.Duration((ttl*120)/100), files)
AnalyzeBenchmarkRuns(results)
AnalyzeBenchmarkRuns("Go-FUSE", results)
}
func TestingBOnePass(b *testing.B, threads int, sleepTime time.Duration, files []string) (results []float64) {
runtime.GC()
runs := b.N + 1
for j := 0; j < runs; j++ {
if j > 0 {
b.StartTimer()
todo := b.N
for todo > 0 {
if len(files) > todo {
files = files[:todo]
}
b.StartTimer()
result := BulkStat(threads, files)
if j > 0 {
todo -= len(files)
b.StopTimer()
results = append(results, result)
} else {
fmt.Println("Ignoring first run to preheat caches.")
}
if j < runs-1 {
fmt.Printf("Sleeping %.2f seconds\n", sleepTime.Seconds())
time.Sleep(sleepTime)
}
}
return results
}
func BenchmarkCFuseThreadedStat(b *testing.B) {
log.Println("benchmarking CFuse")
b.StopTimer()
lines := GetTestLines()
unique := map[string]int{}
......@@ -240,7 +232,6 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
}
f.Close()
log.Println("Written:", f.Name())
mountPoint, _ := ioutil.TempDir("", "stat_test")
wd, _ := os.Getwd()
cmd := exec.Command(wd+"/cstatfs",
......@@ -265,8 +256,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
// Wait for the daemon to mount.
time.Sleep(200 * time.Millisecond)
ttl := time.Millisecond * 100
log.Println("N = ", b.N)
threads := runtime.GOMAXPROCS(0)
results := TestingBOnePass(b, threads, time.Duration((ttl*12)/10), lines)
AnalyzeBenchmarkRuns(results)
AnalyzeBenchmarkRuns("CFuse", results)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment