Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vscode/vscode-perf

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vscode/vscode-perf - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

67

out/perf.js

@@ -219,2 +219,4 @@ "use strict";

});
const cdp = await page.context().newCDPSession(page);
const heapTracing = await startHeapTracing(cdp);
if (options.verbose) {

@@ -230,3 +232,3 @@ page.on('pageerror', error => console.error(`Playwright ERROR: page error: ${error}`));

}
return new Promise(resolve => {
return new Promise(async (resolve) => {
page.on('console', async (msg) => {

@@ -240,5 +242,5 @@ const text = msg.text();

if (matches?.[1]) {
const { heapUsed, heapFreed } = await collectHeapStats(page);
const { majorGCs, minorGCs, allocated, garbage, duration } = await heapTracing.stop();
browser.close();
fs.appendFileSync(perfFile, `${matches[1]}\tHeap: ${Math.round(heapUsed / MB)}MB (used) ${Math.round(heapFreed / MB)}MB (garbage)\n`);
fs.appendFileSync(perfFile, `${matches[1]}\tHeap: ${Math.round(allocated / MB)}MB (used) ${Math.round(garbage / MB)}MB (garbage) ${majorGCs} (MajorGC) ${minorGCs} (MinorGC) ${duration}ms (GC duration)\n`);
resolve(`${durationMarker} ${matches[1]}`);

@@ -250,15 +252,50 @@ }

}
async function collectHeapStats(page) {
try {
const cdp = await page.context().newCDPSession(page);
const heapUsed = (await cdp.send("Runtime.getHeapUsage")).usedSize;
await cdp.send("HeapProfiler.collectGarbage");
const heapFreed = heapUsed - (await cdp.send("Runtime.getHeapUsage")).usedSize;
return { heapUsed, heapFreed };
}
catch (error) {
console.error(`Playwright ERROR: failed to collect heap stats: ${error}`);
return { heapUsed: 0, heapFreed: 0 };
}
async function startHeapTracing(cdp) {
await cdp.send('Tracing.start', { traceConfig: { includedCategories: ['v8'] } });
const data = [];
cdp.on('Tracing.dataCollected', e => {
data.push(...e.value);
});
return {
stop: async () => {
const tracingComplete = new Promise(resolve => cdp.once('Tracing.tracingComplete', resolve));
await cdp.send('Tracing.end');
await tracingComplete;
let minorGCs = 0;
let majorGCs = 0;
let garbage = 0;
let duration = 0;
for (const entry of data) {
const isMinorGC = entry.name === 'MinorGC';
const isMajorGC = entry.name === 'MajorGC';
if (!isMinorGC && !isMajorGC) {
continue;
}
if (isMinorGC) {
minorGCs++;
}
else if (isMajorGC) {
majorGCs++;
}
duration += entry.dur;
garbage += (entry.args.usedHeapSizeBefore - entry.args.usedHeapSizeAfter);
}
const heapSnapshot = await collectHeapSnaptshot(cdp);
garbage += heapSnapshot.garbage;
return {
minorGCs,
majorGCs,
allocated: heapSnapshot.allocated + garbage,
garbage,
duration: Math.round(duration / 1000)
};
}
};
}
async function collectHeapSnaptshot(cdp) {
const usedSizeBeforeGC = (await cdp.send("Runtime.getHeapUsage")).usedSize;
await cdp.send("HeapProfiler.collectGarbage");
const usedSizeAfterGC = (await cdp.send("Runtime.getHeapUsage")).usedSize;
return { allocated: usedSizeAfterGC, garbage: usedSizeBeforeGC - usedSizeAfterGC };
}
function logMarker(content, marker, durations) {

@@ -265,0 +302,0 @@ const regex = new RegExp(`${escapeRegExpCharacters(marker)}\\s+(\\d+)`);

{
"name": "@vscode/vscode-perf",
"version": "0.0.16",
"version": "0.0.17",
"description": "Tooling for evaluating performance of VS Code",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc