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
Kirill Smelkov
go-fuse
Commits
fff4a3ab
Commit
fff4a3ab
authored
May 24, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add example/statfs/ for profiling pathfs.
parent
21e01a3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
example/statfs/main.go
example/statfs/main.go
+83
-0
No files found.
example/statfs/main.go
0 → 100644
View file @
fff4a3ab
package
main
import
(
"flag"
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/benchmark"
"io"
"log"
"os"
"os/exec"
"runtime"
"runtime/pprof"
"strings"
"time"
)
var
_
=
log
.
Printf
func
main
()
{
// Scans the arg list and sets up flags
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"print debugging messages."
)
latencies
:=
flag
.
Bool
(
"latencies"
,
false
,
"record operation latencies."
)
profile
:=
flag
.
String
(
"profile"
,
""
,
"record cpu profile."
)
mem_profile
:=
flag
.
String
(
"mem-profile"
,
""
,
"record memory profile."
)
command
:=
flag
.
String
(
"run"
,
""
,
"run this command after mounting."
)
ttl
:=
flag
.
Float64
(
"ttl"
,
1.0
,
"attribute/entry cache TTL."
)
flag
.
Parse
()
if
flag
.
NArg
()
<
2
{
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: %s MOUNTPOINT FILENAMES-FILE
\n
"
,
os
.
Args
[
0
])
os
.
Exit
(
2
)
}
var
profFile
,
memProfFile
io
.
Writer
var
err
error
if
*
profile
!=
""
{
profFile
,
err
=
os
.
Create
(
*
profile
)
if
err
!=
nil
{
log
.
Fatalf
(
"os.Create: %v"
,
err
)
}
}
if
*
mem_profile
!=
""
{
memProfFile
,
err
=
os
.
Create
(
*
mem_profile
)
if
err
!=
nil
{
log
.
Fatalf
(
"os.Create: %v"
,
err
)
}
}
fs
:=
benchmark
.
NewStatFs
()
lines
:=
benchmark
.
ReadLines
(
flag
.
Arg
(
1
))
for
_
,
l
:=
range
lines
{
fs
.
AddFile
(
l
)
}
nfs
:=
fuse
.
NewPathNodeFs
(
fs
,
nil
)
opts
:=
&
fuse
.
FileSystemOptions
{
AttrTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
EntryTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
}
state
,
_
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
nfs
,
opts
)
if
err
!=
nil
{
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
state
.
SetRecordStatistics
(
*
latencies
)
state
.
Debug
=
*
debug
runtime
.
GC
()
if
profFile
!=
nil
{
pprof
.
StartCPUProfile
(
profFile
)
defer
pprof
.
StopCPUProfile
()
}
if
*
command
!=
""
{
args
:=
strings
.
Split
(
*
command
,
" "
)
cmd
:=
exec
.
Command
(
args
[
0
],
args
[
1
:
]
...
)
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Start
()
}
state
.
Loop
()
if
memProfFile
!=
nil
{
pprof
.
WriteHeapProfile
(
memProfFile
)
}
}
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