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