summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networkQuality.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/networkQuality.go b/networkQuality.go
index ef80d03..5efbc8a 100644
--- a/networkQuality.go
+++ b/networkQuality.go
@@ -12,6 +12,7 @@ import (
"net/http"
"net/url"
"os"
+ "runtime/pprof"
"strings"
"time"
@@ -29,6 +30,7 @@ var (
debug = flag.Bool("debug", false, "Enable debugging.")
timeout = flag.Int("timeout", 20, "Maximum time to spend measuring.")
storeSslKeys = flag.Bool("store-ssl-keys", false, "Store SSL keys from connections for debugging. (currently unused)")
+ profile = flag.String("profile", "", "Enable client runtime profiling and specify storage location. Disabled by default.")
// Global configuration
cooldownPeriod time.Duration = 4 * time.Second
@@ -300,6 +302,16 @@ func main() {
fmt.Printf("Test will end earlier than %v\n", timeoutAbsoluteTime)
}
+ if len(*profile) != 0 {
+ f, err := os.Create(*profile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error: Profiling requested with storage in %s but that file could not be opened: %v\n", *profile, err)
+ return
+ }
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+ }
+
generate_lbd := func() lbc.LoadBearingConnection {
return &lbc.LoadBearingConnectionDownload{Path: config.Urls.LargeUrl}
}