Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
6281a8be
Commit
6281a8be
authored
May 09, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compute stddev, median and 10/90 percentile stats as well.
parent
8988ee1f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
7 deletions
+42
-7
example/bulkstat/bulkstat.go
example/bulkstat/bulkstat.go
+42
-7
No files found.
example/bulkstat/bulkstat.go
View file @
6281a8be
...
@@ -4,13 +4,15 @@ package main
...
@@ -4,13 +4,15 @@ 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"
"encoding/line"
"os"
"flag"
"flag"
"time"
"fmt"
"fmt"
"encoding/line"
"github.com/hanwen/go-fuse/fuse"
"math"
"os"
"runtime"
"runtime"
"sort"
"time"
)
)
func
main
()
{
func
main
()
{
...
@@ -41,25 +43,58 @@ func main() {
...
@@ -41,25 +43,58 @@ func main() {
files
=
append
(
files
,
string
(
l
))
files
=
append
(
files
,
string
(
l
))
}
}
tot
:=
0.0
totalRuns
:=
*
runs
+
1
totalRuns
:=
*
runs
+
1
results
:=
make
([]
float64
,
0
)
for
j
:=
0
;
j
<
totalRuns
;
j
++
{
for
j
:=
0
;
j
<
totalRuns
;
j
++
{
result
:=
BulkStat
(
*
threads
,
files
)
result
:=
BulkStat
(
*
threads
,
files
)
if
j
>
0
{
if
j
>
0
{
tot
+=
result
results
=
append
(
results
,
result
)
}
else
{
}
else
{
fmt
.
Println
(
"Ignoring first run to preheat caches."
)
fmt
.
Println
(
"Ignoring first run to preheat caches."
)
}
}
if
j
<
totalRuns
-
1
{
if
j
<
totalRuns
-
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
))
Analyze
(
results
)
}
func
Analyze
(
times
[]
float64
)
{
sorted
:=
sort
.
Float64Array
(
times
)
sorted
.
Sort
()
tot
:=
0.0
for
_
,
v
:=
range
times
{
tot
+=
v
}
n
:=
float64
(
len
(
times
))
avg
:=
tot
/
n
variance
:=
0.0
for
_
,
v
:=
range
times
{
variance
+=
(
v
-
avg
)
*
(
v
-
avg
)
}
variance
/=
n
stddev
:=
math
.
Sqrt
(
variance
)
median
:=
sorted
[
len
(
times
)
/
2
]
perc90
:=
sorted
[
int
(
n
*
0.9
)]
perc10
:=
sorted
[
int
(
n
*
0.1
)]
fmt
.
Printf
(
"%d samples
\n
"
+
"avg %.2f ms 2sigma %.2f "
+
"median %.2fms
\n
"
+
"10%%tile %.2fms, 90%%tile %.2fms
\n
"
,
len
(
times
),
avg
,
2
*
stddev
,
median
,
perc10
,
perc90
)
}
}
// Returns milliseconds.
func
BulkStat
(
parallelism
int
,
files
[]
string
)
float64
{
func
BulkStat
(
parallelism
int
,
files
[]
string
)
float64
{
todo
:=
make
(
chan
string
,
len
(
files
))
todo
:=
make
(
chan
string
,
len
(
files
))
dts
:=
make
(
chan
int64
,
parallelism
)
dts
:=
make
(
chan
int64
,
parallelism
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment