|
|
@ -31,6 +31,7 @@ type BenchmarkOptions struct { |
|
|
|
sequentialRead *bool |
|
|
|
collection *string |
|
|
|
cpuprofile *string |
|
|
|
maxCpu *int |
|
|
|
vid2server map[string]string //cache for vid locations
|
|
|
|
} |
|
|
|
|
|
|
@ -51,7 +52,8 @@ func init() { |
|
|
|
b.read = cmdBenchmark.Flag.Bool("read", true, "enable read") |
|
|
|
b.sequentialRead = cmdBenchmark.Flag.Bool("readSequentially", false, "randomly read by ids from \"-list\" specified file") |
|
|
|
b.collection = cmdBenchmark.Flag.String("collection", "benchmark", "write data to this collection") |
|
|
|
b.cpuprofile = cmdBenchmark.Flag.String("cpuprofile", "", "write cpu profile to file") |
|
|
|
b.cpuprofile = cmdBenchmark.Flag.String("cpuprofile", "", "cpu profile output file") |
|
|
|
b.maxCpu = cmdBenchmark.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs") |
|
|
|
b.vid2server = make(map[string]string) |
|
|
|
} |
|
|
|
|
|
|
@ -100,6 +102,10 @@ func init() { |
|
|
|
|
|
|
|
func runbenchmark(cmd *Command, args []string) bool { |
|
|
|
fmt.Printf("This is Seaweed File System version %s %s %s\n", util.VERSION, runtime.GOOS, runtime.GOARCH) |
|
|
|
if *b.maxCpu < 1 { |
|
|
|
*b.maxCpu = runtime.NumCPU() |
|
|
|
} |
|
|
|
runtime.GOMAXPROCS(*b.maxCpu) |
|
|
|
if *b.cpuprofile != "" { |
|
|
|
f, err := os.Create(*b.cpuprofile) |
|
|
|
if err != nil { |
|
|
@ -497,9 +503,9 @@ func (l *FakeReader) Read(p []byte) (n int, err error) { |
|
|
|
} else { |
|
|
|
n = len(p) |
|
|
|
} |
|
|
|
for i := 0; i < n-8; i += 8 { |
|
|
|
for s := uint(0); s < 8; s++ { |
|
|
|
p[i] = byte(l.id >> (s * 8)) |
|
|
|
if n >= 8 { |
|
|
|
for i := 0; i < 8; i++ { |
|
|
|
p[i] = byte(l.id >> uint(i*8)) |
|
|
|
} |
|
|
|
} |
|
|
|
l.size -= int64(n) |
|
|
|