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
7ea8b832
Commit
7ea8b832
authored
May 16, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code to profile zipfs.
parent
a519b679
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
4 deletions
+47
-4
example/zipfs/main.go
example/zipfs/main.go
+47
-4
No files found.
example/zipfs/main.go
View file @
7ea8b832
...
...
@@ -5,8 +5,14 @@ import (
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/zipfs"
"io"
"log"
"os"
"os/exec"
"runtime"
"runtime/pprof"
"strings"
"time"
)
var
_
=
log
.
Printf
...
...
@@ -15,21 +21,43 @@ 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 ZIP-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
)
}
}
var
fs
fuse
.
NodeFileSystem
fs
,
err
:
=
zipfs
.
NewArchiveFileSystem
(
flag
.
Arg
(
1
))
fs
,
err
=
zipfs
.
NewArchiveFileSystem
(
flag
.
Arg
(
1
))
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"NewArchiveFileSystem failed: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
state
,
_
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
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
),
fs
,
opts
)
if
err
!=
nil
{
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
@@ -37,5 +65,20 @@ func main() {
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
.
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