Commit 5db91988 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Split up example subdirectory.

parent ef4a0d88
# Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc
TARG=bulkstat
GOFILES=bulkstat.go
include $(GOROOT)/src/Make.cmd
......@@ -36,6 +36,7 @@ func main() {
todo := make(chan string, len(files))
dts := make(chan int64, parallel)
fmt.Printf("Statting %d files with %d threads\n", len(files), parallel)
for i := 0 ; i < parallel; i++ {
go func() {
for {
......
......@@ -9,27 +9,12 @@ import (
"os"
"flag"
"runtime"
"sort"
"log"
)
var _ = runtime.GOMAXPROCS
var _ = log.Print
func PrintMap(m map[string]float64) {
keys := make([]string, len(m))
for k, _ := range m {
keys = append(keys, k)
}
sort.SortStrings(keys)
for _, k := range keys {
if m[k] > 0 {
fmt.Println(k, m[k])
}
}
}
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
......@@ -47,10 +32,6 @@ func main() {
var opts fuse.PathFileSystemConnectorOptions
opts.AttrTimeout = 0.0
opts.EntryTimeout = 0.0
opts.NegativeTimeout = 0.0
fs.FillOptions(&opts)
conn := fuse.NewPathFileSystemConnector(timing)
......@@ -77,7 +58,7 @@ func main() {
latency := state.Latencies()
fmt.Println("Operation latency (ms):")
PrintMap(latency)
fuse.PrintMap(latency)
latency = rawTiming.Latencies()
fmt.Println("\n\nRaw FS (ms):", latency)
......
......@@ -3,7 +3,7 @@ include $(GOROOT)/src/Make.inc
TARG=loopback
GOFILES=loopback.go
DEPS=../examplelib ../fuse
DEPS=../../fuse
include $(GOROOT)/src/Make.cmd
// Mounts another directory as loopback for testing and benchmarking
// purposes.
package main
import (
"github.com/hanwen/go-fuse/fuse"
"fmt"
"os"
"flag"
"runtime"
"log"
)
var _ = runtime.GOMAXPROCS
var _ = log.Print
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
threaded := flag.Bool("threaded", true, "switch off threading; print debugging messages.")
flag.Parse()
if flag.NArg() < 2 {
// TODO - where to get program name?
fmt.Println("usage: main ORIGINAL MOUNTPOINT")
os.Exit(2)
}
orig := flag.Arg(0)
fs := fuse.NewLoopbackFileSystem(orig)
timing := fuse.NewTimingPathFilesystem(fs)
var opts fuse.PathFileSystemConnectorOptions
fs.FillOptions(&opts)
conn := fuse.NewPathFileSystemConnector(timing)
rawTiming := fuse.NewTimingRawFilesystem(conn)
conn.SetOptions(opts)
state := fuse.NewMountState(rawTiming)
state.Debug = *debug
mountPoint := flag.Arg(1)
err := state.Mount(mountPoint)
if err != nil {
fmt.Printf("MountFuse fail: %v\n", err)
os.Exit(1)
}
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v)\n", orig, mountPoint, *threaded, *debug)
state.Loop(*threaded)
fmt.Println("Finished", state.Stats())
fmt.Println("\n\nMountState statistics\n")
counts := state.OperationCounts()
fmt.Println("Counts: ", counts)
latency := state.Latencies()
fmt.Println("Operation latency (ms):")
fuse.PrintMap(latency)
latency = rawTiming.Latencies()
fmt.Println("\n\nRaw FS (ms):", latency)
fmt.Println("\n\nLoopback FS statistics\n")
latency = timing.Latencies()
fmt.Println("Latency (ms):", latency)
fmt.Println("Operation counts:", timing.OperationCounts())
hot, unique := timing.HotPaths("GetAttr")
top := 20
start := len(hot)-top
if start < 0 {
start = 0
}
fmt.Printf("Unique GetAttr paths: %d\n", unique)
fmt.Printf("Top %d GetAttr paths: %v", top, hot[start:])
}
# Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc
TARG=multizip
GOFILES=multizip.go
DEPS=../../fuse ../../examplelib
include $(GOROOT)/src/Make.cmd
# Use "gomake install" to build and install this package.
include $(GOROOT)/src/Make.inc
TARG=zipfs
GOFILES=zipfs.go
DEPS=../../fuse ../../examplelib
include $(GOROOT)/src/Make.cmd
package main
import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/examplelib"
"fmt"
"flag"
"log"
"os"
)
var _ = log.Printf
func main() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
flag.Parse()
if flag.NArg() < 2 {
// TODO - where to get program name?
fmt.Println("usage: main MOUNTPOINT ZIP-FILE")
os.Exit(2)
}
fs := examplelib.NewZipArchiveFileSystem(flag.Arg(1))
conn := fuse.NewPathFileSystemConnector(fs)
state := fuse.NewMountState(conn)
mountPoint := flag.Arg(0)
state.Debug = *debug
state.Mount(mountPoint)
fmt.Printf("Mounted %s - PID %s\n", mountPoint, fuse.MyPID())
state.Loop(true)
latency := state.Latencies()
fmt.Println("Operation latency (ms):")
fuse.PrintMap(latency)
fmt.Println("Memory stats", state.Stats())
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment