Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix(stack): use unique pointer not i (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa authored Nov 8, 2022
1 parent f7bba52 commit 3ec6bfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bindings/cpu_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::tuple <v8::Local<v8::Value>, v8::Local<v8::Value>, v8::Local<v8::Value>> Ge
stack_index = stack_index_cache_hit->second;
}
else {
stack_lookup_table.insert({ node_hash, i });
stack_lookup_table.insert({ node_hash, stack_index });
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/cpu_profiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const assertValidSamplesAndStacks = (stacks: ThreadCpuProfile['stacks'], samples
expect(stacks.length).toBeGreaterThan(0);
expect(samples.length).toBeGreaterThan(0);
expect(stacks.length <= samples.length).toBe(true);

for (const sample of samples) {
if (!stacks[sample.stack_id]) {
throw new Error(`Failed to find stack for sample: ${JSON.stringify(sample)}`);
}
expect(stacks[sample.stack_id]).not.toBe(undefined);
}

for (const stack of stacks) {
expect(stack).not.toBe(undefined);
}
Expand Down Expand Up @@ -113,7 +121,6 @@ describe('Profiler bindings', () => {
});

if (!profile) fail('Profile is null');
console.log(profile.stacks);
assertValidSamplesAndStacks(profile.stacks, profile.samples);
});

Expand Down

0 comments on commit 3ec6bfb

Please sign in to comment.