mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-14 00:14:45 +00:00
add cpu profiling
This commit is contained in:
parent
a71d1eb59b
commit
11a3e8f64f
2 changed files with 16 additions and 0 deletions
|
|
@ -3,7 +3,9 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"sync"
|
||||
|
||||
"github.com/yannh/kubeconform/pkg/config"
|
||||
|
|
@ -51,6 +53,18 @@ func realMain() int {
|
|||
return 1
|
||||
}
|
||||
|
||||
if cfg.CPUProfileFile != "" {
|
||||
f, err := os.Create(cfg.CPUProfileFile)
|
||||
if err != nil {
|
||||
log.Fatal("could not create CPU profile: ", err)
|
||||
}
|
||||
defer f.Close()
|
||||
if err := pprof.StartCPUProfile(f); err != nil {
|
||||
log.Fatal("could not start CPU profile: ", err)
|
||||
}
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
// Detect whether we have data being piped through stdin
|
||||
stat, _ := os.Stdin.Stat()
|
||||
isStdin := (stat.Mode() & os.ModeCharDevice) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue