mirror of
https://github.com/JaCoB1123/dupe-finder.git
synced 2025-05-18 06:01:56 +02:00
Add Flag to enable cpu profiling
This commit is contained in:
parent
29fa093184
commit
594a88c3ec
12
main.go
12
main.go
@ -6,9 +6,11 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -21,10 +23,20 @@ var promptForDelete = flag.Bool("delete-prompt", false, "Ask which file to keep
|
|||||||
var moveToFolder = flag.String("move-files", "", "Move files to <path> instead of deleting them")
|
var moveToFolder = flag.String("move-files", "", "Move files to <path> instead of deleting them")
|
||||||
var force = flag.Bool("force", false, "Actually delete files. Without this options, the files to be deleted are only printed")
|
var force = flag.Bool("force", false, "Actually delete files. Without this options, the files to be deleted are only printed")
|
||||||
var verbose = flag.Bool("verbose", false, "Output additional information")
|
var verbose = flag.Bool("verbose", false, "Output additional information")
|
||||||
|
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *cpuprofile != "" {
|
||||||
|
f, err := os.Create(*cpuprofile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
pprof.StartCPUProfile(f)
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
if *verbose {
|
if *verbose {
|
||||||
printConfiguration()
|
printConfiguration()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user