Skip to content

Commit

Permalink
Fix profiler code
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoNex committed Oct 26, 2023
1 parent e434da1 commit 6919a03
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package main

import (
"flag"
"os"
"runtime/pprof"

Expand Down Expand Up @@ -38,8 +37,8 @@ func code(path string) string {
}

func fileOrDefault() string {
if flag.NArg() > 0 {
return code(flag.Arg(0))
if len(os.Args) > 1 {
return code(os.Args[1])
}
return fib
}
Expand All @@ -48,13 +47,14 @@ func main() {
cpuf, err := os.Create("cpu.prof")
check(err)

tree, errs := parser.Parse("<profiler>", fileOrDefault())
tauCode := fileOrDefault()
tree, errs := parser.Parse("<profiler>", tauCode)
if len(errs) > 0 {
panic("parser errors")
}

c := compiler.New()
c.SetFileInfo("<profiler>", fib)
c.SetFileInfo("<profiler>", tauCode)
check(c.Compile(tree))

check(pprof.StartCPUProfile(cpuf))
Expand Down

0 comments on commit 6919a03

Please sign in to comment.