We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3f8d980 + 839c0a7 commit 68e04d9Copy full SHA for 68e04d9
cmd/pbr/main.go
@@ -4,6 +4,7 @@ import (
4
"fmt"
5
"os"
6
"strings"
7
+ "runtime/pprof"
8
9
"github.com/hunterloftis/pbr/pkg/camera"
10
"github.com/hunterloftis/pbr/pkg/env"
@@ -30,7 +31,29 @@ func main() {
30
31
}
32
33
34
+func createProfile() (*os.File, error) {
35
+ f, err := os.Create("profile.pprof")
36
+ if err != nil {
37
+ return nil, err
38
+ }
39
+ pprof.StartCPUProfile(f)
40
+ return f, nil
41
+}
42
+
43
+func stopProfile(f *os.File) {
44
+ pprof.StopCPUProfile()
45
+ f.Close()
46
47
48
func run(o *Options) error {
49
+ if o.Profile {
50
+ f, err := createProfile()
51
52
+ return err
53
54
+ defer stopProfile(f)
55
56
57
mesh, err := obj.ReadFile(o.Scene, true)
58
if err != nil {
59
return err
0 commit comments