Commit 7b2a08f2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Automatically set the number of threads in bulkstat.

parent 93d87c60
...@@ -3,6 +3,7 @@ include $(GOROOT)/src/Make.inc ...@@ -3,6 +3,7 @@ include $(GOROOT)/src/Make.inc
TARG=bulkstat TARG=bulkstat
GOFILES=bulkstat.go GOFILES=bulkstat.go
DEPS=../../fuse
include $(GOROOT)/src/Make.cmd include $(GOROOT)/src/Make.cmd
...@@ -4,20 +4,25 @@ package main ...@@ -4,20 +4,25 @@ package main
// in parallel. This is useful for benchmarking purposes. // in parallel. This is useful for benchmarking purposes.
import ( import (
"github.com/hanwen/go-fuse/fuse"
"os" "os"
"flag" "flag"
"time" "time"
"fmt" "fmt"
"encoding/line" "encoding/line"
"runtime"
) )
func main() { func main() {
threads := flag.Int("threads", 12, "number of parallel threads in a run.") threads := flag.Int("threads", 0, "number of parallel threads in a run. If 0, use CPU count.")
sleepTime := flag.Float64("sleep", 4.0, "amount of sleep between runs.") sleepTime := flag.Float64("sleep", 4.0, "amount of sleep between runs.")
runs := flag.Int("runs", 10, "number of runs.") runs := flag.Int("runs", 10, "number of runs.")
flag.Parse() flag.Parse()
if *threads == 0 {
*threads = fuse.CountCpus()
runtime.GOMAXPROCS(*threads)
}
filename := flag.Args()[0] filename := flag.Args()[0]
f, err := os.Open(filename) f, err := os.Open(filename)
if err != nil { if err != nil {
......
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