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 (
)
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()
filename := flag.Args()[0]
......@@ -32,27 +36,26 @@ func main() {
files = append(files, string(l))
}
runs := 10
tot := 0.0
sleeptime := 4.0
for j := 0; j < runs; j++ {
tot += BulkStat(10, files)
fmt.Printf("Sleeping %.2f seconds\n", sleeptime)
time.Sleep(int64(sleeptime * 1e9))
for j := *runs; j > 0; j-- {
tot += BulkStat(*threads, files)
if j > 1 {
fmt.Printf("Sleeping %.2f seconds\n", *sleepTime)
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 {
parallel := 10
todo := make(chan string, len(files))
dts := make(chan int64, parallel)
dts := make(chan int64, parallelism)
allStart := time.Nanoseconds()
fmt.Printf("Statting %d files with %d threads\n", len(files), parallel)
for i := 0; i < parallel; i++ {
fmt.Printf("Statting %d files with %d threads\n", len(files), parallelism)
for i := 0; i < parallelism; i++ {
go func() {
for {
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