Skip to content

Commit

Permalink
fix: flame graph aggregation logic (#59)
Browse files Browse the repository at this point in the history
Fixed a bug that caused metrics to be aggregated on the basis of just
the scope name.

Fixes #58.
  • Loading branch information
P403n1x87 authored Jan 10, 2024
1 parent b2a16af commit fe2c279
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [0.17.1]

- Fixed a visualisation bug that caused some frames to be aggregated incorrectly
by scope name only, resulting in incorrect flame graph visualisations.

## [0.17.0]

- Added support for the `${file}` and `${workspaceFolder}` placeholders in the
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Austin VS Code",
"publisher": "p403n1x87",
"description": "Austin extension for VS Code",
"version": "0.17.0",
"version": "0.17.1",
"engines": {
"vscode": "^1.57.0"
},
Expand Down
13 changes: 9 additions & 4 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class AustinStats implements AustinStats {
this.overallTotal = 0;
this.top = new Map();
this.hierarchy = {
key: "",
name: "",
value: 0,
children: [],
Expand All @@ -94,6 +95,7 @@ export class AustinStats implements AustinStats {
this.locationMap.clear();
this.overallTotal = 0;
this.hierarchy = {
key: "",
name: this.source!,
value: 0,
children: [],
Expand Down Expand Up @@ -179,16 +181,17 @@ export class AustinStats implements AustinStats {
stats.value += metric;

let updateContainer = (container: D3Hierarchy[], frame: FrameObject, keyFactory: (frame: FrameObject) => string, newDataFactory: (frame: FrameObject) => any) => {
const name: string = keyFactory(frame);
const key: string = keyFactory(frame);
for (let e of container) {
if (e.name === name) {
if (e.key === key) {
e.value += metric;
return e.children;
}
}
const newContainer: D3Hierarchy[] = [];
container.push({
name: name,
key: key,
name: frame.scope,
value: metric,
children: newContainer,
data: newDataFactory(frame),
Expand All @@ -205,6 +208,7 @@ export class AustinStats implements AustinStats {
}
const newContainer: D3Hierarchy[] = [];
container.push({
key: key,
name: key,
value: metric,
children: newContainer,
Expand Down Expand Up @@ -236,7 +240,7 @@ export class AustinStats implements AustinStats {
container = updateContainer(
container,
fo,
(fo) => { return fo.scope; /*fo.module && fo.line ? `${fo.scope} (${fo.module})` : fo.scope;*/ },
(fo) => { return `${fo.module}:${fo.scope}`; },
(fo) => {
return {
file: fo.module,
Expand Down Expand Up @@ -408,6 +412,7 @@ function parseFrame(frame: string): FrameObject {


interface D3Hierarchy {
key: string;
name: string;
value: number;
children: D3Hierarchy[];
Expand Down

0 comments on commit fe2c279

Please sign in to comment.