2019-01-31 09:07:06 -05:00
|
|
|
/* exported run, script_desktopShown, script_overviewShowStart,
|
|
|
|
script_overviewShowDone, script_applicationsShowStart,
|
|
|
|
script_applicationsShowDone, script_mainViewDrawStart,
|
|
|
|
script_mainViewDrawDone, script_overviewDrawStart,
|
|
|
|
script_overviewDrawDone, script_redrawTestStart,
|
|
|
|
script_redrawTestDone, script_collectTimings,
|
|
|
|
script_geditLaunch, script_geditFirstFrame,
|
|
|
|
clutter_stagePaintStart, clutter_paintCompletedTimestamp */
|
2019-01-31 19:16:20 -05:00
|
|
|
/* eslint camelcase: ["error", { properties: "never", allow: ["^script_", "^clutter"] }] */
|
2019-04-04 09:45:01 -04:00
|
|
|
const { Clutter, Gio, Shell } = imports.gi;
|
2014-06-05 15:18:25 -04:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const Scripting = imports.ui.scripting;
|
|
|
|
|
2019-03-05 16:54:59 -05:00
|
|
|
var METRICS = {
|
2014-06-05 15:18:25 -04:00
|
|
|
timeToDesktop:
|
|
|
|
{ description: "Time from starting graphical.target to desktop showing",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
overviewShowTime:
|
|
|
|
{ description: "Time to switch to overview view, first time",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
applicationsShowTime:
|
|
|
|
{ description: "Time to switch to applications view, first time",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
mainViewRedrawTime:
|
|
|
|
{ description: "Time to redraw the main view, full screen",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
overviewRedrawTime:
|
|
|
|
{ description: "Time to redraw the overview, full screen, 5 windows",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
applicationRedrawTime:
|
|
|
|
{ description: "Time to redraw frame with a maximized application update",
|
|
|
|
units: "us" },
|
|
|
|
|
|
|
|
geditStartTime:
|
|
|
|
{ description: "Time from gedit launch to window drawn",
|
|
|
|
units: "us" },
|
2019-01-28 20:18:52 -05:00
|
|
|
};
|
2014-06-05 15:18:25 -04:00
|
|
|
|
|
|
|
function waitAndDraw(milliseconds) {
|
|
|
|
let cb;
|
|
|
|
|
|
|
|
let timeline = new Clutter.Timeline({ duration: milliseconds });
|
|
|
|
timeline.start();
|
|
|
|
|
2019-02-04 06:30:53 -05:00
|
|
|
timeline.connect('new-frame', (_timeline, _frame) => {
|
2017-10-30 20:38:18 -04:00
|
|
|
global.stage.queue_redraw();
|
|
|
|
});
|
|
|
|
|
|
|
|
timeline.connect('completed', () => {
|
|
|
|
timeline.stop();
|
|
|
|
if (cb)
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
|
2019-01-27 19:42:00 -05:00
|
|
|
return callback => cb = callback;
|
2014-06-05 15:18:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function waitSignal(object, signal) {
|
|
|
|
let cb;
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let id = object.connect(signal, () => {
|
2014-06-05 15:18:25 -04:00
|
|
|
object.disconnect(id);
|
|
|
|
if (cb)
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
|
2019-01-27 19:42:00 -05:00
|
|
|
return callback => cb = callback;
|
2014-06-05 15:18:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function extractBootTimestamp() {
|
|
|
|
let sp = Gio.Subprocess.new(['journalctl', '-b',
|
|
|
|
'MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5',
|
|
|
|
'UNIT=graphical.target',
|
|
|
|
'-o',
|
2014-07-16 13:20:15 -04:00
|
|
|
'json'],
|
2014-06-05 15:18:25 -04:00
|
|
|
Gio.SubprocessFlags.STDOUT_PIPE);
|
|
|
|
let result = null;
|
|
|
|
|
|
|
|
let datastream = Gio.DataInputStream.new(sp.get_stdout_pipe());
|
2019-02-04 07:14:09 -05:00
|
|
|
while (true) { // eslint-disable-line no-constant-condition
|
2019-01-31 09:08:00 -05:00
|
|
|
let [line, length_] = datastream.read_line_utf8(null);
|
2014-06-05 15:18:25 -04:00
|
|
|
if (line === null)
|
|
|
|
break;
|
|
|
|
|
2014-07-16 13:20:15 -04:00
|
|
|
let fields = JSON.parse(line);
|
|
|
|
result = Number(fields['__MONOTONIC_TIMESTAMP']);
|
2014-06-05 15:18:25 -04:00
|
|
|
}
|
|
|
|
datastream.close(null);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-01-27 20:57:00 -05:00
|
|
|
function *run() {
|
2014-06-05 15:18:25 -04:00
|
|
|
Scripting.defineScriptEvent("desktopShown", "Finished initial animation");
|
|
|
|
Scripting.defineScriptEvent("overviewShowStart", "Starting to show the overview");
|
|
|
|
Scripting.defineScriptEvent("overviewShowDone", "Overview finished showing");
|
|
|
|
Scripting.defineScriptEvent("applicationsShowStart", "Starting to switch to applications view");
|
|
|
|
Scripting.defineScriptEvent("applicationsShowDone", "Done switching to applications view");
|
|
|
|
Scripting.defineScriptEvent("mainViewDrawStart", "Drawing main view");
|
|
|
|
Scripting.defineScriptEvent("mainViewDrawDone", "Ending timing main view drawing");
|
|
|
|
Scripting.defineScriptEvent("overviewDrawStart", "Drawing overview");
|
|
|
|
Scripting.defineScriptEvent("overviewDrawDone", "Ending timing overview drawing");
|
|
|
|
Scripting.defineScriptEvent("redrawTestStart", "Drawing application window");
|
|
|
|
Scripting.defineScriptEvent("redrawTestDone", "Ending timing application window drawing");
|
|
|
|
Scripting.defineScriptEvent("collectTimings", "Accumulate frame timings from redraw tests");
|
|
|
|
Scripting.defineScriptEvent("geditLaunch", "gedit application launch");
|
|
|
|
Scripting.defineScriptEvent("geditFirstFrame", "first frame of gedit window drawn");
|
|
|
|
|
|
|
|
yield Scripting.waitLeisure();
|
|
|
|
Scripting.scriptEvent('desktopShown');
|
|
|
|
|
2019-04-04 09:45:01 -04:00
|
|
|
let interfaceSettings = new Gio.Settings({
|
|
|
|
schema_id: 'org.gnome.desktop.interface'
|
|
|
|
});
|
|
|
|
interfaceSettings.set_boolean('enable-animations', false);
|
2014-06-05 15:18:25 -04:00
|
|
|
|
|
|
|
Scripting.scriptEvent('overviewShowStart');
|
|
|
|
Main.overview.show();
|
|
|
|
yield Scripting.waitLeisure();
|
|
|
|
Scripting.scriptEvent('overviewShowDone');
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('applicationsShowStart');
|
2019-06-29 09:14:37 -04:00
|
|
|
// eslint-disable-next-line require-atomic-updates
|
2014-06-05 15:18:25 -04:00
|
|
|
Main.overview._dash.showAppsButton.checked = true;
|
|
|
|
|
|
|
|
yield Scripting.waitLeisure();
|
|
|
|
Scripting.scriptEvent('applicationsShowDone');
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
Main.overview.hide();
|
|
|
|
yield Scripting.waitLeisure();
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
|
|
|
// Tests of redraw speed
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
global.frame_timestamps = true;
|
|
|
|
global.frame_finish_timestamp = true;
|
|
|
|
|
|
|
|
for (let k = 0; k < 5; k++)
|
2018-04-25 17:47:06 -04:00
|
|
|
yield Scripting.createTestWindow({ maximized: true });
|
2014-06-05 15:18:25 -04:00
|
|
|
yield Scripting.waitTestWindows();
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('mainViewDrawStart');
|
|
|
|
yield waitAndDraw(1000);
|
|
|
|
Scripting.scriptEvent('mainViewDrawDone');
|
|
|
|
|
|
|
|
Main.overview.show();
|
|
|
|
Scripting.waitLeisure();
|
|
|
|
|
|
|
|
yield Scripting.sleep(1500);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('overviewDrawStart');
|
|
|
|
yield waitAndDraw(1000);
|
|
|
|
Scripting.scriptEvent('overviewDrawDone');
|
|
|
|
|
|
|
|
yield Scripting.destroyTestWindows();
|
|
|
|
Main.overview.hide();
|
|
|
|
|
2018-04-25 17:47:06 -04:00
|
|
|
yield Scripting.createTestWindow({ maximized: true,
|
2019-01-28 20:27:05 -05:00
|
|
|
redraws: true });
|
2014-06-05 15:18:25 -04:00
|
|
|
yield Scripting.waitTestWindows();
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('redrawTestStart');
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
Scripting.scriptEvent('redrawTestDone');
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
Scripting.scriptEvent('collectTimings');
|
|
|
|
|
|
|
|
yield Scripting.destroyTestWindows();
|
|
|
|
|
|
|
|
global.frame_timestamps = false;
|
|
|
|
global.frame_finish_timestamp = false;
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
////////////////////////////////////////
|
2014-09-03 13:47:06 -04:00
|
|
|
|
2014-06-05 15:18:25 -04:00
|
|
|
let appSys = Shell.AppSystem.get_default();
|
2014-07-25 04:39:10 -04:00
|
|
|
let app = appSys.lookup_app('org.gnome.gedit.desktop');
|
2014-06-05 15:18:25 -04:00
|
|
|
|
|
|
|
Scripting.scriptEvent('geditLaunch');
|
|
|
|
app.activate();
|
|
|
|
|
|
|
|
let windows = app.get_windows();
|
|
|
|
if (windows.length > 0)
|
|
|
|
throw new Error('gedit was already running');
|
|
|
|
|
|
|
|
while (windows.length == 0) {
|
|
|
|
yield waitSignal(global.display, 'window-created');
|
|
|
|
windows = app.get_windows();
|
|
|
|
}
|
|
|
|
|
|
|
|
let actor = windows[0].get_compositor_private();
|
|
|
|
yield waitSignal(actor, 'first-frame');
|
|
|
|
Scripting.scriptEvent('geditFirstFrame');
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
|
|
|
windows[0].delete(global.get_current_time());
|
|
|
|
|
|
|
|
yield Scripting.sleep(1000);
|
|
|
|
|
2019-04-04 09:45:01 -04:00
|
|
|
interfaceSettings.set_boolean('enable-animations', true);
|
2014-06-05 15:18:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let overviewShowStart;
|
|
|
|
let applicationsShowStart;
|
|
|
|
let stagePaintStart;
|
|
|
|
let redrawTiming;
|
|
|
|
let redrawTimes = {};
|
|
|
|
let geditLaunchTime;
|
|
|
|
|
|
|
|
function script_desktopShown(time) {
|
|
|
|
let bootTimestamp = extractBootTimestamp();
|
|
|
|
METRICS.timeToDesktop.value = time - bootTimestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_overviewShowStart(time) {
|
|
|
|
overviewShowStart = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_overviewShowDone(time) {
|
|
|
|
METRICS.overviewShowTime.value = time - overviewShowStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_applicationsShowStart(time) {
|
|
|
|
applicationsShowStart = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_applicationsShowDone(time) {
|
|
|
|
METRICS.applicationsShowTime.value = time - applicationsShowStart;
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_mainViewDrawStart(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = 'mainView';
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_mainViewDrawDone(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = null;
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_overviewDrawStart(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = 'overview';
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_overviewDrawDone(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = null;
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_redrawTestStart(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = 'application';
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_redrawTestDone(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
redrawTiming = null;
|
|
|
|
}
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
function script_collectTimings(_time) {
|
2014-06-05 15:18:25 -04:00
|
|
|
for (let timing in redrawTimes) {
|
|
|
|
let times = redrawTimes[timing];
|
2017-10-30 20:38:18 -04:00
|
|
|
times.sort((a, b) => a - b);
|
2014-06-05 15:18:25 -04:00
|
|
|
|
|
|
|
let len = times.length;
|
|
|
|
let median;
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
median = -1;
|
|
|
|
else if (len % 2 == 1)
|
2019-01-28 20:27:05 -05:00
|
|
|
median = times[(len - 1) / 2];
|
2014-06-05 15:18:25 -04:00
|
|
|
else
|
|
|
|
median = Math.round((times[len / 2 - 1] + times[len / 2]) / 2);
|
|
|
|
|
2019-01-29 19:18:24 -05:00
|
|
|
METRICS[`${timing}RedrawTime`].value = median;
|
2014-06-05 15:18:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_geditLaunch(time) {
|
|
|
|
geditLaunchTime = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function script_geditFirstFrame(time) {
|
|
|
|
METRICS.geditStartTime.value = time - geditLaunchTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clutter_stagePaintStart(time) {
|
|
|
|
stagePaintStart = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clutter_paintCompletedTimestamp(time) {
|
|
|
|
if (redrawTiming != null && stagePaintStart != null) {
|
|
|
|
if (!(redrawTiming in redrawTimes))
|
|
|
|
redrawTimes[redrawTiming] = [];
|
|
|
|
redrawTimes[redrawTiming].push(time - stagePaintStart);
|
|
|
|
}
|
|
|
|
stagePaintStart = null;
|
|
|
|
}
|