@datadog/pprof
Advanced tools
Comparing version
@@ -26,3 +26,3 @@ /** | ||
*/ | ||
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper): Profile; | ||
export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper, recomputeSamplingInterval?: boolean): Profile; | ||
/** | ||
@@ -29,0 +29,0 @@ * Converts cpu profile into into a profile proto. |
@@ -168,2 +168,6 @@ "use strict"; | ||
} | ||
function computeTotalHitCount(root) { | ||
return (root.hitCount + | ||
root.children.reduce((sum, node) => sum + computeTotalHitCount(node), 0)); | ||
} | ||
/** | ||
@@ -176,3 +180,13 @@ * Converts v8 time profile into into a profile proto. | ||
*/ | ||
function serializeTimeProfile(prof, intervalMicros, sourceMapper) { | ||
function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSamplingInterval = false) { | ||
// If requested, recompute sampling interval it from profile duration and total number of hits, | ||
// since profile duration should be #hits x interval | ||
// Recomputing an average interval is more accurate, since in practice intervals between | ||
// samples are larger than the requested sampling interval (eg. 12.5ms vs 10ms requested). | ||
if (recomputeSamplingInterval) { | ||
const totalHitCount = computeTotalHitCount(prof.topDownRoot); | ||
if (totalHitCount > 0) { | ||
intervalMicros = Math.floor((prof.endTime - prof.startTime) / computeTotalHitCount(prof.topDownRoot)); | ||
} | ||
} | ||
const intervalNanos = intervalMicros * 1000; | ||
@@ -179,0 +193,0 @@ const appendTimeEntryToSamples = (entry, samples) => { |
@@ -52,3 +52,3 @@ "use strict"; | ||
} | ||
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper); | ||
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper, true); | ||
} | ||
@@ -69,3 +69,3 @@ // For Node.js v16+, we want to start the next profile before we stop the | ||
profiler.dispose(); | ||
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper); | ||
return (0, profile_serializer_1.serializeTimeProfile)(result, intervalMicros, sourceMapper, true); | ||
} | ||
@@ -72,0 +72,0 @@ } |
{ | ||
"name": "@datadog/pprof", | ||
"version": "2.0.0-pre-eb60cf3", | ||
"version": "2.0.0", | ||
"description": "pprof support for Node.js", | ||
@@ -32,3 +32,3 @@ "repository": "datadog/pprof-nodejs", | ||
"pify": "^5.0.0", | ||
"pprof-format": "^2.0.5", | ||
"pprof-format": "^2.0.6", | ||
"source-map": "^0.7.3", | ||
@@ -35,0 +35,0 @@ "split": "^1.0.1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
10465135
0.01%1380
1.02%1
-50%Updated