Bug 1348031: Part 1 - Allow specifying fractional-millisecond startup profiling interval. r?mstange draft
authorKris Maglione <maglione.k@gmail.com>
Mon, 15 May 2017 14:19:12 -0700
changeset 578079 7d65c38c7ca74106b587d718609c687136c022a8
parent 578063 c63d8286d4548cd385947dc8c4895800b1e793f2
child 578080 5f60d056202c8282b117c071ea78d9dfd13ee045
push id58886
push usermaglione.k@gmail.com
push dateMon, 15 May 2017 21:25:33 +0000
reviewersmstange
bugs1348031
milestone55.0a1
Bug 1348031: Part 1 - Allow specifying fractional-millisecond startup profiling interval. r?mstange MozReview-Commit-ID: Ga1ebO03gp5
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -34,16 +34,17 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsMemoryReporterManager.h"
 #include "nsXULAppAPI.h"
 #include "nsProfilerStartParams.h"
 #include "mozilla/Services.h"
 #include "nsThreadUtils.h"
 #include "ProfilerMarkerPayload.h"
 #include "shared-libraries.h"
+#include "prdtoa.h"
 #include "prtime.h"
 
 #ifdef MOZ_TASK_TRACER
 #include "GeckoTaskTracer.h"
 #endif
 
 #if defined(GP_OS_android)
 # include "FennecJNINatives.h"
@@ -2069,23 +2070,23 @@ profiler_init(void* aStackTop)
       entries = strtol(startupEntries, nullptr, 10);
       if (errno == 0 && entries > 0) {
         LOG("- MOZ_PROFILER_STARTUP_ENTRIES = %d", entries);
       } else {
         PrintUsageThenExit(1);
       }
     }
 
-    int interval = PROFILER_DEFAULT_INTERVAL;
+    double interval = PROFILER_DEFAULT_INTERVAL;
     const char* startupInterval = getenv("MOZ_PROFILER_STARTUP_INTERVAL");
     if (startupInterval) {
       errno = 0;
-      interval = strtol(startupInterval, nullptr, 10);
-      if (errno == 0 && 1 <= interval && interval <= 1000) {
-        LOG("- MOZ_PROFILER_STARTUP_INTERVAL = %d", interval);
+      interval = PR_strtod(startupInterval, nullptr);
+      if (errno == 0 && interval > 0.0 && interval <= 1000.0) {
+        LOG("- MOZ_PROFILER_STARTUP_INTERVAL = %f", interval);
       } else {
         PrintUsageThenExit(1);
       }
     }
 
     locked_profiler_start(lock, entries, interval, features,
                           filters, MOZ_ARRAY_LENGTH(filters));
   }