Commit 9bebb442 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Make bulkstat tunable over the command line.

parent 22c2700d
...@@ -12,6 +12,10 @@ import ( ...@@ -12,6 +12,10 @@ import (
) )
func main() { func main() {
threads := flag.Int("threads", 12, "number of parallel threads in a run.")
sleepTime := flag.Float64("sleep", 4.0, "amount of sleep between runs.")
runs := flag.Int("runs", 10, "number of runs.")
flag.Parse() flag.Parse()
filename := flag.Args()[0] filename := flag.Args()[0]
...@@ -32,27 +36,26 @@ func main() { ...@@ -32,27 +36,26 @@ func main() {
files = append(files, string(l)) files = append(files, string(l))
} }
runs := 10
tot := 0.0 tot := 0.0
sleeptime := 4.0 for j := *runs; j > 0; j-- {
for j := 0; j < runs; j++ { tot += BulkStat(*threads, files)
tot += BulkStat(10, files) if j > 1 {
fmt.Printf("Sleeping %.2f seconds\n", sleeptime) fmt.Printf("Sleeping %.2f seconds\n", *sleepTime)
time.Sleep(int64(sleeptime * 1e9)) time.Sleep(int64(*sleepTime * 1e9))
}
} }
fmt.Printf("Average of %d runs: %f ms\n", runs, tot/float64(runs)) fmt.Printf("Average of %d runs: %f ms\n", *runs, tot/float64(*runs))
} }
func BulkStat(parallelism int, files []string) float64 { func BulkStat(parallelism int, files []string) float64 {
parallel := 10
todo := make(chan string, len(files)) todo := make(chan string, len(files))
dts := make(chan int64, parallel) dts := make(chan int64, parallelism)
allStart := time.Nanoseconds() allStart := time.Nanoseconds()
fmt.Printf("Statting %d files with %d threads\n", len(files), parallel) fmt.Printf("Statting %d files with %d threads\n", len(files), parallelism)
for i := 0; i < parallel; i++ { for i := 0; i < parallelism; i++ {
go func() { go func() {
for { for {
fn := <-todo fn := <-todo
......
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