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
ef4a0d88
Commit
ef4a0d88
authored
Mar 23, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bulkstat.go benchmarking program.
parent
f3f990a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
example/bulkstat.go
example/bulkstat.go
+64
-0
No files found.
example/bulkstat.go
0 → 100644
View file @
ef4a0d88
package
main
// Given a file with filenames, this times how fast we can stat them
// in parallel. This is useful for benchmarking purposes.
import
(
"os"
"flag"
"time"
"fmt"
"encoding/line"
)
func
main
()
{
flag
.
Parse
()
filename
:=
flag
.
Args
()[
0
]
f
,
err
:=
os
.
Open
(
filename
,
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
panic
(
"err"
+
err
.
String
())
}
linelen
:=
1000
reader
:=
line
.
NewReader
(
f
,
linelen
)
files
:=
make
([]
string
,
0
)
for
{
l
,
_
,
err
:=
reader
.
ReadLine
()
if
err
!=
nil
{
break
}
files
=
append
(
files
,
string
(
l
))
}
parallel
:=
10
todo
:=
make
(
chan
string
,
len
(
files
))
dts
:=
make
(
chan
int64
,
parallel
)
for
i
:=
0
;
i
<
parallel
;
i
++
{
go
func
()
{
for
{
fn
:=
<-
todo
if
fn
==
""
{
break
}
t
:=
time
.
Nanoseconds
()
os
.
Lstat
(
fn
)
dts
<-
time
.
Nanoseconds
()
-
t
}
}()
}
for
_
,
v
:=
range
files
{
todo
<-
v
}
total
:=
0.0
for
i
:=
0
;
i
<
len
(
files
);
i
++
{
total
+=
float64
(
<-
dts
)
*
1e-6
}
fmt
.
Println
(
"Average stat time (ms):"
,
total
/
float64
(
len
(
files
)))
}
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