Skip to content

Commit 295923e

Browse files
committed
better name for global, simpler util for workbench.js, microsoft#101850
1 parent 003a367 commit 295923e

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

src/vs/base/common/performance.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99

1010
function _factory(sharedObj) {
1111

12-
sharedObj._performanceEntries = sharedObj._performanceEntries || [];
12+
sharedObj.MonacoPerformanceMarks = sharedObj.MonacoPerformanceMarks || [];
1313

1414
const _dataLen = 2;
1515
const _timeStamp = typeof console.timeStamp === 'function' ? console.timeStamp.bind(console) : () => { };
1616

1717
function importEntries(entries) {
18-
sharedObj._performanceEntries.splice(0, 0, ...entries);
18+
sharedObj.MonacoPerformanceMarks.splice(0, 0, ...entries);
1919
}
2020

2121
function exportEntries() {
22-
return sharedObj._performanceEntries.slice(0);
22+
return sharedObj.MonacoPerformanceMarks.slice(0);
2323
}
2424

2525
function getEntries() {
2626
const result = [];
27-
const entries = sharedObj._performanceEntries;
27+
const entries = sharedObj.MonacoPerformanceMarks;
2828
for (let i = 0; i < entries.length; i += _dataLen) {
2929
result.push({
3030
name: entries[i],
@@ -35,7 +35,7 @@ function _factory(sharedObj) {
3535
}
3636

3737
function getDuration(from, to) {
38-
const entries = sharedObj._performanceEntries;
38+
const entries = sharedObj.MonacoPerformanceMarks;
3939
let target = to;
4040
let endIndex = 0;
4141
for (let i = entries.length - _dataLen; i >= 0; i -= _dataLen) {
@@ -54,7 +54,7 @@ function _factory(sharedObj) {
5454
}
5555

5656
function mark(name) {
57-
sharedObj._performanceEntries.push(name, Date.now());
57+
sharedObj.MonacoPerformanceMarks.push(name, Date.now());
5858
_timeStamp(name);
5959
}
6060

src/vs/code/electron-browser/workbench/workbench.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,13 @@
99
'use strict';
1010

1111
const perf = (function () {
12-
let sharedObj;
13-
if (typeof global === 'object') {
14-
// nodejs
15-
sharedObj = global;
16-
} else if (typeof self === 'object') {
17-
// browser
18-
sharedObj = self;
19-
} else {
20-
sharedObj = {};
21-
}
22-
// @ts-ignore
23-
sharedObj._performanceEntries = sharedObj._performanceEntries || [];
12+
globalThis.MonacoPerformanceMarks = globalThis.MonacoPerformanceMarks || [];
2413
return {
2514
/**
2615
* @param {string} name
2716
*/
2817
mark(name) {
29-
sharedObj._performanceEntries.push(name, Date.now());
18+
globalThis.MonacoPerformanceMarks.push(name, Date.now());
3019
}
3120
};
3221
})();

0 commit comments

Comments
 (0)