<commit_before>// 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

type PathPrintingFs struct {
	fuse.WrappingPathFilesystem
}

func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
	log.Println(name)
	return me.Original.GetAttr(name)
}

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)
	}

	var fs fuse.PathFilesystem
	orig := flag.Arg(0)
	loopbackfs := fuse.NewLoopbackFileSystem(orig)
	fs = loopbackfs
	timing := fuse.NewTimingPathFilesystem(fs)
	fs = timing

	if *debug {
		pp := new(PathPrintingFs)
		pp.Original = fs
		fs = pp
	}

	var opts fuse.PathFileSystemConnectorOptions

	loopbackfs.FillOptions(&opts)

	conn := fuse.NewPathFileSystemConnector(fs)
	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):")<commit_msg>Switch order of loopback binary arguments.<commit_after>// 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

type PathPrintingFs struct {
	fuse.WrappingPathFilesystem
}

func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
	log.Println(name)
	return me.Original.GetAttr(name)
}

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 MOUNTPOINT ORIGINAL")
		os.Exit(2)
	}

	var fs fuse.PathFilesystem
	orig := flag.Arg(1)
	loopbackfs := fuse.NewLoopbackFileSystem(orig)
	fs = loopbackfs
	timing := fuse.NewTimingPathFilesystem(fs)
	fs = timing

	if *debug {
		pp := new(PathPrintingFs)
		pp.Original = fs
		fs = pp
	}

	var opts fuse.PathFileSystemConnectorOptions

	loopbackfs.FillOptions(&opts)

	conn := fuse.NewPathFileSystemConnector(fs)
	rawTiming := fuse.NewTimingRawFilesystem(conn)
	conn.SetOptions(opts)

	state := fuse.NewMountState(rawTiming)
	state.Debug = *debug

	mountPoint := flag.Arg(0)
	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):")
{'fraction_non_alphanumeric': 0.14118629908103592, 'fraction_numerical': 0.00278473962684489, 'mean_word_length': 4.483969465648855, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2106536', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1306, 'n_words': 300}