Skip to content

Commit 5a97263

Browse files
authored
Merge pull request #81 from microsoft/fix/empty-profile-error
fix: don't error out on empty profile
2 parents 654b8a7 + a78b09e commit 5a97263

File tree

10 files changed

+24
-12
lines changed

10 files changed

+24
-12
lines changed

.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module.exports = {
1616
rules: {
1717
'@typescript-eslint/no-use-before-define': 'off',
1818
'@typescript-eslint/explicit-function-return-type': 'off',
19-
'@typescript-eslint/interface-name-prefix': ['error', { prefixWithI: 'always' }],
2019
'react/display-name': 'off',
2120
'react/prop-types': 'off',
2221
'header/header': [

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "1.0.2"
5+
"version": "1.0.3"
66
}

packages/vscode-js-profile-core/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-js-profile-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-js-profile-core",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"sideEffects": false,
55
"private": true,
66
"scripts": {

packages/vscode-js-profile-core/src/cpu/model.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ describe('model', () => {
1111
expect(buildModel(profiles[i])).toMatchSnapshot();
1212
});
1313
}
14+
15+
it('does not error on empty, profile', () => {
16+
buildModel({
17+
nodes: [],
18+
samples: [],
19+
timeDeltas: [],
20+
startTime: 1654100488066000,
21+
endTime: 1654100490779000,
22+
$vscode: { rootPath: '.', locations: [] },
23+
});
24+
});
1425
});
1526

1627
const profiles = [

packages/vscode-js-profile-core/src/cpu/model.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,10 @@ export const buildModel = (profile: ICpuProfileRaw): IProfileModel => {
229229
// time before the first sample, and the time of the last sample is only
230230
// derived (approximately) by the missing time in the sum of deltas. Save
231231
// some work by calculating it here.
232-
nodes[mapId(samples[timeDeltas.length - 1])].selfTime += lastNodeTime;
233-
timeDeltas.push(lastNodeTime);
232+
if (nodes.length) {
233+
nodes[mapId(samples[timeDeltas.length - 1])].selfTime += lastNodeTime;
234+
timeDeltas.push(lastNodeTime);
235+
}
234236

235237
// 3. Add the aggregate times for all node children and locations
236238
for (let i = 0; i < nodes.length; i++) {

packages/vscode-js-profile-flame/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-js-profile-flame/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-js-profile-flame",
33
"displayName": "Flame Chart Visualizer for JavaScript Profiles",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "Flame graph visualizer for profiles taken from the JavaScript debugger",
66
"author": "Connor Peet <[email protected]>",
77
"homepage": "https://github.com/microsoft/vscode-js-profile-visualizer#readme",
@@ -169,7 +169,7 @@
169169
"dependencies": {
170170
"@vscode/codicons": "^0.0.30",
171171
"chroma-js": "^2.4.2",
172-
"vscode-js-profile-core": "^1.0.2",
172+
"vscode-js-profile-core": "^1.0.3",
173173
"vscode-webview-tools": "^0.1.1"
174174
}
175175
}

packages/vscode-js-profile-table/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-js-profile-table/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-js-profile-table",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"displayName": "Table Visualizer for JavaScript Profiles",
55
"description": "Text visualizer for profiles taken from the JavaScript debugger",
66
"author": "Connor Peet <[email protected]>",
@@ -86,6 +86,6 @@
8686
},
8787
"dependencies": {
8888
"@vscode/codicons": "^0.0.28",
89-
"vscode-js-profile-core": "^1.0.2"
89+
"vscode-js-profile-core": "^1.0.3"
9090
}
9191
}

0 commit comments

Comments
 (0)