Skip to content

Commit 9829b82

Browse files
authored
fix(profiling) sample timestamps need to be in seconds (#12563)
1 parent be1b816 commit 9829b82

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/profiling-node/bindings/cpu_profiler.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ CreateFrameNode(const napi_env &env, const v8::CpuProfileNode &node,
546546
};
547547

548548
napi_value CreateSample(const napi_env &env, const enum ProfileFormat format,
549-
const uint32_t stack_id, const int64_t sample_timestamp,
549+
const uint32_t stack_id,
550+
const int64_t sample_timestamp_ns,
550551
const double chunk_timestamp,
551552
const uint32_t thread_id) {
552553
napi_value js_node;
@@ -564,7 +565,7 @@ napi_value CreateSample(const napi_env &env, const enum ProfileFormat format,
564565
switch (format) {
565566
case ProfileFormat::kFormatThread: {
566567
napi_value timestamp;
567-
napi_create_int64(env, sample_timestamp, &timestamp);
568+
napi_create_int64(env, sample_timestamp_ns, &timestamp);
568569
napi_set_named_property(env, js_node, "elapsed_since_start_ns", timestamp);
569570
} break;
570571
case ProfileFormat::kFormatChunk: {
@@ -643,7 +644,8 @@ static void GetSamples(const napi_env &env, const v8::CpuProfile *profile,
643644
uint64_t sample_offset_from_profile_start_ms =
644645
(sample_timestamp_us - profile_start_time_us) * 1e-3;
645646
double seconds_since_start =
646-
profile_start_timestamp_ms + sample_offset_from_profile_start_ms;
647+
(profile_start_timestamp_ms + sample_offset_from_profile_start_ms) *
648+
1e-3;
647649

648650
napi_value sample = nullptr;
649651
sample = CreateSample(env, format, stack_index, sample_timestamp_ns,

0 commit comments

Comments
 (0)