commit
457598e1b6
49
hsbench.go
49
hsbench.go
|
@ -6,6 +6,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"code.cloudfoundry.org/bytefmt"
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
|
@ -15,6 +16,10 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -29,11 +34,6 @@ import (
|
|||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"code.cloudfoundry.org/bytefmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
// Global variables
|
||||
|
@ -148,11 +148,11 @@ type IntervalStats struct {
|
|||
func (is *IntervalStats) makeOutputStats() OutputStats {
|
||||
// Compute and log the stats
|
||||
ops := len(is.latNano)
|
||||
totalLat := int64(0);
|
||||
minLat := float64(0);
|
||||
maxLat := float64(0);
|
||||
NinetyNineLat := float64(0);
|
||||
avgLat := float64(0);
|
||||
totalLat := int64(0)
|
||||
minLat := float64(0)
|
||||
maxLat := float64(0)
|
||||
NinetyNineLat := float64(0)
|
||||
avgLat := float64(0)
|
||||
if ops > 0 {
|
||||
minLat = float64(is.latNano[0]) / 1000000
|
||||
maxLat = float64(is.latNano[ops-1]) / 1000000
|
||||
|
@ -386,14 +386,14 @@ func (stats *Stats) makeOutputStats(i int64) (OutputStats, bool) {
|
|||
func (stats *Stats) makeTotalStats() (OutputStats, bool) {
|
||||
// Not safe to log if not all writers have completed.
|
||||
completions := atomic.LoadInt32(&stats.completions)
|
||||
if (completions < int32(threads)) {
|
||||
if completions < int32(threads) {
|
||||
log.Printf("log, completions: %d", completions)
|
||||
return OutputStats{}, false
|
||||
}
|
||||
|
||||
bytes := int64(0)
|
||||
ops := int64(0)
|
||||
slowdowns := int64(0);
|
||||
slowdowns := int64(0)
|
||||
|
||||
for t := 0; t < stats.threads; t++ {
|
||||
for i := 0; i < len(stats.threadStats[t].intervals); i++ {
|
||||
|
@ -501,7 +501,7 @@ func runUpload(thread_num int, fendtime time.Time, stats *Stats) {
|
|||
|
||||
if err != nil {
|
||||
errcnt++
|
||||
stats.addSlowDown(thread_num);
|
||||
stats.addSlowDown(thread_num)
|
||||
atomic.AddInt64(&op_counter, -1)
|
||||
log.Printf("upload err", err)
|
||||
} else {
|
||||
|
@ -545,7 +545,7 @@ func runDownload(thread_num int, fendtime time.Time, stats *Stats) {
|
|||
|
||||
if err != nil {
|
||||
errcnt++
|
||||
stats.addSlowDown(thread_num);
|
||||
stats.addSlowDown(thread_num)
|
||||
log.Printf("download err", err)
|
||||
} else {
|
||||
// Update the stats
|
||||
|
@ -595,7 +595,7 @@ func runDelete(thread_num int, stats *Stats) {
|
|||
|
||||
if err != nil {
|
||||
errcnt++
|
||||
stats.addSlowDown(thread_num);
|
||||
stats.addSlowDown(thread_num)
|
||||
log.Printf("delete err", err, "out", out.String())
|
||||
} else {
|
||||
// Update the stats
|
||||
|
@ -721,37 +721,37 @@ func runWrapper(loop int, r rune) []OutputStats {
|
|||
log.Printf("Running Loop %d BUCKET CLEAR TEST", loop)
|
||||
stats = makeStats(loop, "BCLR", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runBucketsClear(n, &stats);
|
||||
go runBucketsClear(n, &stats)
|
||||
}
|
||||
case 'x':
|
||||
log.Printf("Running Loop %d BUCKET DELETE TEST", loop)
|
||||
stats = makeStats(loop, "BDEL", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runBucketDelete(n, &stats);
|
||||
go runBucketDelete(n, &stats)
|
||||
}
|
||||
case 'i':
|
||||
log.Printf("Running Loop %d BUCKET INIT TEST", loop)
|
||||
stats = makeStats(loop, "BINIT", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runBucketsInit(n, &stats);
|
||||
go runBucketsInit(n, &stats)
|
||||
}
|
||||
case 'p':
|
||||
log.Printf("Running Loop %d OBJECT PUT TEST", loop)
|
||||
stats = makeStats(loop, "PUT", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runUpload(n, endtime, &stats);
|
||||
go runUpload(n, endtime, &stats)
|
||||
}
|
||||
case 'g':
|
||||
log.Printf("Running Loop %d OBJECT GET TEST", loop)
|
||||
stats = makeStats(loop, "GET", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runDownload(n, endtime, &stats);
|
||||
go runDownload(n, endtime, &stats)
|
||||
}
|
||||
case 'd':
|
||||
log.Printf("Running Loop %d OBJECT DELETE TEST", loop)
|
||||
stats = makeStats(loop, "DEL", threads, intervalNano)
|
||||
for n := 0; n < threads; n++ {
|
||||
go runDelete(n, &stats);
|
||||
go runDelete(n, &stats)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ NOTES:
|
|||
fmt.Fprintf(flag.CommandLine.Output(), "\nUSAGE: %s [OPTIONS]\n\n", os.Args[0])
|
||||
fmt.Fprintf(flag.CommandLine.Output(), "OPTIONS:\n")
|
||||
myflag.PrintDefaults()
|
||||
fmt.Fprintf(flag.CommandLine.Output(), notes);
|
||||
fmt.Fprintf(flag.CommandLine.Output(), notes)
|
||||
}
|
||||
|
||||
if err := myflag.Parse(os.Args[1:]); err != nil {
|
||||
|
@ -845,13 +845,12 @@ NOTES:
|
|||
}
|
||||
invalid_mode := false
|
||||
for _, r := range modes {
|
||||
if (
|
||||
r != 'i' &&
|
||||
if r != 'i' &&
|
||||
r != 'c' &&
|
||||
r != 'p' &&
|
||||
r != 'g' &&
|
||||
r != 'd' &&
|
||||
r != 'x') {
|
||||
r != 'x' {
|
||||
s := fmt.Sprintf("Invalid mode '%s' passed to -m", string(r))
|
||||
log.Printf(s)
|
||||
invalid_mode = true
|
||||
|
|
Loading…
Reference in New Issue