File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "flag"
5
+ "os"
6
+ "runtime/pprof"
7
+
4
8
"github.com/DDP-Projekt/DDPLS/ddpls"
9
+ "github.com/DDP-Projekt/DDPLS/log"
5
10
"github.com/tliron/kutil/logging"
6
11
7
12
// Must include a backend implementation. See kutil's logging/ for other options.
8
13
_ "github.com/tliron/kutil/logging/simple"
9
14
)
10
15
11
16
func main () {
17
+ var cpuprofile string
18
+ flag .StringVar (& cpuprofile , "cpuprofile" , "" , "write cpu profile to file" )
19
+ flag .Parse ()
20
+
12
21
// This increases logging verbosity (optional)
13
22
logging .Configure (1 , nil )
14
23
15
- ddpls := ddpls .NewDDPLS ()
16
- ddpls .Server .RunStdio ()
24
+ ls := ddpls .NewDDPLS ()
25
+
26
+ if cpuprofile != "" {
27
+ f , err := os .Create (cpuprofile )
28
+ if err != nil {
29
+ log .Warningf ("error creating cpuprofile file: %w" , err )
30
+ } else {
31
+ defer f .Close ()
32
+ if err := pprof .StartCPUProfile (f ); err != nil {
33
+ log .Warningf ("error starting cpuprofile: %w" , err )
34
+ } else {
35
+ defer pprof .StopCPUProfile ()
36
+ }
37
+ }
38
+ }
39
+
40
+ ls .Server .RunStdio ()
17
41
}
You can’t perform that action at this time.
0 commit comments