2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 19:16:20 -05:00
|
|
|
/* eslint camelcase: ["error", { properties: "never", allow: ["^script_", "^malloc", "^glx", "^clutter"] }] */
|
2010-05-09 13:42:35 -04:00
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
import * as System from 'system';
|
2012-07-12 19:59:52 -04:00
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
|
|
|
import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js';
|
2010-05-09 13:42:35 -04:00
|
|
|
|
|
|
|
// This performance script measure the most important (core) performance
|
|
|
|
// metrics for the shell. By looking at the output metrics of this script
|
|
|
|
// someone should be able to get an idea of how well the shell is performing
|
|
|
|
// on a particular system.
|
|
|
|
|
2023-06-12 20:13:01 -04:00
|
|
|
export var METRICS = {
|
2020-03-29 17:51:13 -04:00
|
|
|
overviewLatencyFirst: {
|
|
|
|
description: 'Time to first frame after triggering overview, first time',
|
|
|
|
units: 'us',
|
|
|
|
},
|
|
|
|
overviewFpsFirst: {
|
|
|
|
description: 'Frame rate when going to the overview, first time',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewLatencySubsequent: {
|
|
|
|
description: 'Time to first frame after triggering overview, second time',
|
|
|
|
units: 'us',
|
|
|
|
},
|
|
|
|
overviewFpsSubsequent: {
|
|
|
|
description: 'Frames rate when going to the overview, second time',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps5Windows: {
|
|
|
|
description: 'Frames rate when going to the overview, 5 windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps10Windows: {
|
|
|
|
description: 'Frames rate when going to the overview, 10 windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps5Maximized: {
|
|
|
|
description: 'Frames rate when going to the overview, 5 maximized windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps10Maximized: {
|
|
|
|
description: 'Frames rate when going to the overview, 10 maximized windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps5Alpha: {
|
|
|
|
description: 'Frames rate when going to the overview, 5 alpha-transparent windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
overviewFps10Alpha: {
|
|
|
|
description: 'Frames rate when going to the overview, 10 alpha-transparent windows open',
|
|
|
|
units: 'frames / s',
|
|
|
|
},
|
|
|
|
usedAfterOverview: {
|
|
|
|
description: "Malloc'ed bytes after the overview is shown once",
|
|
|
|
units: 'B',
|
|
|
|
},
|
|
|
|
leakedAfterOverview: {
|
|
|
|
description: "Additional malloc'ed bytes the second time the overview is shown",
|
|
|
|
units: 'B',
|
|
|
|
},
|
|
|
|
applicationsShowTimeFirst: {
|
|
|
|
description: 'Time to switch to applications view, first time',
|
|
|
|
units: 'us',
|
|
|
|
},
|
|
|
|
applicationsShowTimeSubsequent: {
|
|
|
|
description: 'Time to switch to applications view, second time',
|
|
|
|
units: 'us',
|
|
|
|
},
|
2010-05-09 13:42:35 -04:00
|
|
|
};
|
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
const WINDOW_CONFIGS = [{
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: false, maximized: false, count: 1, metric: 'overviewFpsSubsequent',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: false, maximized: false, count: 5, metric: 'overviewFps5Windows',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: false, maximized: false, count: 10, metric: 'overviewFps10Windows',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: false, maximized: true, count: 5, metric: 'overviewFps5Maximized',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: false, maximized: true, count: 10, metric: 'overviewFps10Maximized',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: true, maximized: false, count: 5, metric: 'overviewFps5Alpha',
|
|
|
|
}, {
|
|
|
|
width: 640, height: 480,
|
|
|
|
alpha: true, maximized: false, count: 10, metric: 'overviewFps10Alpha',
|
|
|
|
}];
|
2011-03-08 18:54:23 -05:00
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/** @returns {void} */
|
2023-06-12 20:13:01 -04:00
|
|
|
export async function run() {
|
2020-07-30 12:41:11 -04:00
|
|
|
/* eslint-disable no-await-in-loop */
|
2023-07-13 15:29:13 -04:00
|
|
|
Scripting.defineScriptEvent('overviewShowStart', 'Starting to show the overview');
|
|
|
|
Scripting.defineScriptEvent('overviewShowDone', 'Overview finished showing');
|
|
|
|
Scripting.defineScriptEvent('afterShowHide', 'After a show/hide cycle for the overview');
|
|
|
|
Scripting.defineScriptEvent('applicationsShowStart', 'Starting to switch to applications view');
|
|
|
|
Scripting.defineScriptEvent('applicationsShowDone', 'Done switching to applications view');
|
2010-05-09 13:42:35 -04:00
|
|
|
|
2014-06-26 20:34:15 -04:00
|
|
|
// Enable recording of timestamps for different points in the frame cycle
|
|
|
|
global.frame_timestamps = true;
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
Main.overview.connect('shown', () => {
|
|
|
|
Scripting.scriptEvent('overviewShowDone');
|
|
|
|
});
|
2010-05-24 10:27:13 -04:00
|
|
|
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.sleep(1000);
|
2011-03-08 18:54:23 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < 2 * WINDOW_CONFIGS.length; i++) {
|
|
|
|
// We go to the overview twice for each configuration; the first time
|
|
|
|
// to calculate the mipmaps for the windows, the second time to get
|
|
|
|
// a clean set of numbers.
|
2023-07-13 15:29:13 -04:00
|
|
|
if ((i % 2) === 0) {
|
2011-03-08 18:54:23 -05:00
|
|
|
let config = WINDOW_CONFIGS[i / 2];
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.destroyTestWindows();
|
2011-03-08 18:54:23 -05:00
|
|
|
|
2019-08-19 20:51:42 -04:00
|
|
|
for (let k = 0; k < config.count; k++) {
|
2020-03-29 17:51:13 -04:00
|
|
|
await Scripting.createTestWindow({
|
|
|
|
width: config.width,
|
|
|
|
height: config.height,
|
|
|
|
alpha: config.alpha,
|
|
|
|
maximized: config.maximized,
|
|
|
|
});
|
2019-08-19 20:51:42 -04:00
|
|
|
}
|
2011-03-08 18:54:23 -05:00
|
|
|
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitTestWindows();
|
|
|
|
await Scripting.sleep(1000);
|
|
|
|
await Scripting.waitLeisure();
|
2011-03-08 18:54:23 -05:00
|
|
|
}
|
|
|
|
|
2010-05-09 13:42:35 -04:00
|
|
|
Scripting.scriptEvent('overviewShowStart');
|
|
|
|
Main.overview.show();
|
2010-05-11 15:53:55 -04:00
|
|
|
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitLeisure();
|
2010-05-09 13:42:35 -04:00
|
|
|
Main.overview.hide();
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitLeisure();
|
2010-05-11 15:53:55 -04:00
|
|
|
|
2012-07-12 19:59:52 -04:00
|
|
|
System.gc();
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.sleep(1000);
|
2010-05-11 15:53:55 -04:00
|
|
|
Scripting.collectStatistics();
|
|
|
|
Scripting.scriptEvent('afterShowHide');
|
2010-05-09 13:42:35 -04:00
|
|
|
}
|
2011-03-08 19:27:30 -05:00
|
|
|
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.destroyTestWindows();
|
|
|
|
await Scripting.sleep(1000);
|
2011-03-08 19:27:30 -05:00
|
|
|
|
|
|
|
Main.overview.show();
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitLeisure();
|
2011-03-08 19:27:30 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < 2; i++) {
|
|
|
|
Scripting.scriptEvent('applicationsShowStart');
|
2019-06-29 09:14:37 -04:00
|
|
|
// eslint-disable-next-line require-atomic-updates
|
2019-08-30 21:51:02 -04:00
|
|
|
Main.overview.dash.showAppsButton.checked = true;
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitLeisure();
|
2011-03-08 19:27:30 -05:00
|
|
|
Scripting.scriptEvent('applicationsShowDone');
|
2019-06-29 09:14:37 -04:00
|
|
|
// eslint-disable-next-line require-atomic-updates
|
2019-08-30 21:51:02 -04:00
|
|
|
Main.overview.dash.showAppsButton.checked = false;
|
2020-07-30 12:41:11 -04:00
|
|
|
await Scripting.waitLeisure();
|
2011-03-08 19:27:30 -05:00
|
|
|
}
|
2020-07-30 12:41:11 -04:00
|
|
|
/* eslint-enable no-await-in-loop */
|
2010-05-09 13:42:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let showingOverview = false;
|
2010-05-24 10:27:13 -04:00
|
|
|
let finishedShowingOverview = false;
|
2010-05-09 13:42:35 -04:00
|
|
|
let overviewShowStart;
|
|
|
|
let overviewFrames;
|
|
|
|
let overviewLatency;
|
2010-05-11 15:53:55 -04:00
|
|
|
let mallocUsedSize = 0;
|
|
|
|
let overviewShowCount = 0;
|
2010-05-24 10:27:13 -04:00
|
|
|
let haveSwapComplete = false;
|
2011-03-08 19:27:30 -05:00
|
|
|
let applicationsShowStart;
|
|
|
|
let applicationsShowCount = 0;
|
2010-05-09 13:42:35 -04:00
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function script_overviewShowStart(time) {
|
2010-05-09 13:42:35 -04:00
|
|
|
showingOverview = true;
|
2010-05-24 10:27:13 -04:00
|
|
|
finishedShowingOverview = false;
|
2010-05-09 13:42:35 -04:00
|
|
|
overviewShowStart = time;
|
|
|
|
overviewFrames = 0;
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} _time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function script_overviewShowDone(_time) {
|
2010-05-24 10:27:13 -04:00
|
|
|
// We've set up the state at the end of the zoom out, but we
|
|
|
|
// need to wait for one more frame to paint before we count
|
|
|
|
// ourselves as done.
|
|
|
|
finishedShowingOverview = true;
|
2010-05-09 13:42:35 -04:00
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function script_applicationsShowStart(time) {
|
2011-03-08 19:27:30 -05:00
|
|
|
applicationsShowStart = time;
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/** @returns {void} */
|
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function script_applicationsShowDone(time) {
|
2011-03-08 19:27:30 -05:00
|
|
|
applicationsShowCount++;
|
2023-07-13 15:29:13 -04:00
|
|
|
if (applicationsShowCount === 1)
|
2011-03-08 19:27:30 -05:00
|
|
|
METRICS.applicationsShowTimeFirst.value = time - applicationsShowStart;
|
|
|
|
else
|
|
|
|
METRICS.applicationsShowTimeSubsequent.value = time - applicationsShowStart;
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/** @returns {void} */
|
|
|
|
/**
|
|
|
|
* @param {number} _time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function script_afterShowHide(_time) {
|
2023-07-13 15:29:13 -04:00
|
|
|
if (overviewShowCount === 1)
|
2010-05-17 14:04:09 -04:00
|
|
|
METRICS.usedAfterOverview.value = mallocUsedSize;
|
2019-08-19 20:51:42 -04:00
|
|
|
else
|
2010-05-17 14:04:09 -04:00
|
|
|
METRICS.leakedAfterOverview.value = mallocUsedSize - METRICS.usedAfterOverview.value;
|
2010-05-11 15:53:55 -04:00
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @param {number} bytes - event data
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function malloc_usedSize(time, bytes) {
|
2010-05-11 15:53:55 -04:00
|
|
|
mallocUsedSize = bytes;
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2010-05-24 10:27:13 -04:00
|
|
|
function _frameDone(time) {
|
2010-05-09 13:42:35 -04:00
|
|
|
if (showingOverview) {
|
2023-07-13 15:29:13 -04:00
|
|
|
if (overviewFrames === 0)
|
2010-05-09 13:42:35 -04:00
|
|
|
overviewLatency = time - overviewShowStart;
|
|
|
|
|
|
|
|
overviewFrames++;
|
|
|
|
}
|
2010-05-24 10:27:13 -04:00
|
|
|
|
|
|
|
if (finishedShowingOverview) {
|
|
|
|
showingOverview = false;
|
|
|
|
finishedShowingOverview = false;
|
|
|
|
overviewShowCount++;
|
|
|
|
|
|
|
|
let dt = (time - (overviewShowStart + overviewLatency)) / 1000000;
|
|
|
|
|
|
|
|
// If we see a start frame and an end frame, that would
|
|
|
|
// be 1 frame for a FPS computation, hence the '- 1'
|
|
|
|
let fps = (overviewFrames - 1) / dt;
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
if (overviewShowCount === 1) {
|
2010-05-24 10:27:13 -04:00
|
|
|
METRICS.overviewLatencyFirst.value = overviewLatency;
|
|
|
|
METRICS.overviewFpsFirst.value = fps;
|
2023-07-13 15:29:13 -04:00
|
|
|
} else if (overviewShowCount === 2) {
|
2010-05-24 10:27:13 -04:00
|
|
|
METRICS.overviewLatencySubsequent.value = overviewLatency;
|
2011-03-08 18:54:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Other than overviewFpsFirst, we collect FPS metrics the second
|
|
|
|
// we show each window configuration. overviewShowCount is 1,2,3...
|
2023-07-13 15:29:13 -04:00
|
|
|
if (overviewShowCount % 2 === 0) {
|
2011-03-08 18:54:23 -05:00
|
|
|
let config = WINDOW_CONFIGS[(overviewShowCount / 2) - 1];
|
|
|
|
METRICS[config.metric].value = fps;
|
2010-05-24 10:27:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @param {number} swapTime - event data
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function glx_swapComplete(time, swapTime) {
|
2010-05-24 10:27:13 -04:00
|
|
|
haveSwapComplete = true;
|
|
|
|
|
|
|
|
_frameDone(swapTime);
|
|
|
|
}
|
|
|
|
|
2023-07-13 15:29:13 -04:00
|
|
|
/**
|
|
|
|
* @param {number} time - event timestamp
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-06-12 20:13:01 -04:00
|
|
|
export function clutter_stagePaintDone(time) {
|
2010-05-24 10:27:13 -04:00
|
|
|
// If we aren't receiving GLXBufferSwapComplete events, then we approximate
|
|
|
|
// the time the user sees a frame with the time we finished doing drawing
|
|
|
|
// commands for the frame. This doesn't take into account the time for
|
|
|
|
// the GPU to finish painting, and the time for waiting for the buffer
|
|
|
|
// swap, but if this are uniform - every frame takes the same time to draw -
|
|
|
|
// then it won't upset our FPS calculation, though the latency value
|
|
|
|
// will be slightly too low.
|
|
|
|
|
|
|
|
if (!haveSwapComplete)
|
|
|
|
_frameDone(time);
|
2010-05-09 13:42:35 -04:00
|
|
|
}
|