File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ $ basic_hmac_auth -h
3939Usage of /usr/local/bin/basic_hmac_auth:
4040 -buffer-size int
4141 initial buffer size for stream parsing
42+ -cpu-profile string
43+ write CPU profile to file
4244 -secret string
4345 hex-encoded HMAC secret value
4446 -secret-file string
Original file line number Diff line number Diff line change 99 "io"
1010 "log"
1111 "os"
12+ "runtime/pprof"
1213
1314 "github.com/SenseUnit/basic_hmac_auth/handler"
1415)
2425 hexSecret = flag .String ("secret" , "" , "hex-encoded HMAC secret value" )
2526 hexSecretFile = flag .String ("secret-file" , "" , "file containing single line with hex-encoded secret" )
2627 showVersion = flag .Bool ("version" , false , "show program version and exit" )
28+ cpuProfile = flag .String ("cpu-profile" , "" , "write CPU profile to file" )
2729)
2830
2931func run () int {
@@ -65,6 +67,16 @@ func run() int {
6567 return 3
6668 }
6769
70+ if * cpuProfile != "" {
71+ f , err := os .Create (* cpuProfile )
72+ if err != nil {
73+ log .Fatal (err )
74+ }
75+ defer f .Close ()
76+ pprof .StartCPUProfile (f )
77+ defer pprof .StopCPUProfile ()
78+ }
79+
6880 err = (& handler.BasicHMACAuthHandler {
6981 Secret : secret ,
7082 BufferSize : * bufferSize ,
You can’t perform that action at this time.
0 commit comments