[perf] Replace window.sk.perf with window.perf.
The extra level of nesting wasn't providing any benefit.
In the long run this templated inlined object should be
replaced with a module.
Change-Id: I4976a86383e9e6a852953285c4196abea109614a
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/586901
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Ravi Mistry <rmistry@google.com>
diff --git a/perf/go/frontend/frontend.go b/perf/go/frontend/frontend.go
index ddb156a..1f71e38 100644
--- a/perf/go/frontend/frontend.go
+++ b/perf/go/frontend/frontend.go
@@ -191,7 +191,7 @@
}
// SkPerfConfig is the configuration data that will appear
-// in Javascript under the sk.perf variable.
+// in Javascript under the window.perf variable.
type SkPerfConfig struct {
Radius int `json:"radius"` // The number of commits when doing clustering.
KeyOrder []string `json:"key_order"` // The order of the keys to appear first in query-sk elements.
@@ -218,7 +218,7 @@
}
b, err := json.MarshalIndent(context, "", " ")
if err != nil {
- sklog.Errorf("Failed to JSON encode sk.perf context: %s", err)
+ sklog.Errorf("Failed to JSON encode window.perf context: %s", err)
}
if err := f.templates.ExecuteTemplate(w, name, map[string]template.JS{"context": template.JS(string(b))}); err != nil {
sklog.Error("Failed to expand template:", err)
diff --git a/perf/modules/alert-config-sk/alert-config-sk-demo.ts b/perf/modules/alert-config-sk/alert-config-sk-demo.ts
index 86aed29..54dcda3 100644
--- a/perf/modules/alert-config-sk/alert-config-sk-demo.ts
+++ b/perf/modules/alert-config-sk/alert-config-sk-demo.ts
@@ -3,10 +3,9 @@
import { AlertConfigSk } from './alert-config-sk';
import { Alert } from '../json';
-window.sk = window.sk || {};
-window.sk.perf = window.sk.perf || {};
-window.sk.perf.key_order = [];
-window.sk.perf.display_group_by = true;
+window.perf = window.perf || {};
+window.perf.key_order = [];
+window.perf.display_group_by = true;
// Force all the alert-config-sk controls on the page to re-render.
const refreshControls = () => {
@@ -17,11 +16,11 @@
};
$$('#display_group_by')!.addEventListener('click', () => {
- window.sk.perf.display_group_by = true;
+ window.perf.display_group_by = true;
refreshControls();
});
$$('#hide_group_by')!.addEventListener('click', () => {
- window.sk.perf.display_group_by = false;
+ window.perf.display_group_by = false;
refreshControls();
});
diff --git a/perf/modules/alert-config-sk/alert-config-sk.ts b/perf/modules/alert-config-sk/alert-config-sk.ts
index 68c3a39..6d6089a 100644
--- a/perf/modules/alert-config-sk/alert-config-sk.ts
+++ b/perf/modules/alert-config-sk/alert-config-sk.ts
@@ -30,7 +30,6 @@
ConfigState,
TryBugRequest,
TryBugResponse,
- SkPerfConfig,
} from '../json';
import { QuerySkQueryChangeEventDetail } from '../../../infra-sk/modules/query-sk/query-sk';
import { AlgoSelectAlgoChangeEventDetail } from '../algo-select-sk/algo-select-sk';
@@ -342,7 +341,7 @@
`;
private static _groupBy = (ele: AlertConfigSk): TemplateResult => {
- if (!window.sk?.perf?.display_group_by) {
+ if (!window.perf?.display_group_by) {
return html``;
}
return html`
@@ -374,8 +373,8 @@
super.connectedCallback();
this._upgradeProperty('config');
this._upgradeProperty('paramset');
- if (window.sk?.perf?.key_order) {
- this._key_order = window.sk.perf.key_order;
+ if (window.perf?.key_order) {
+ this._key_order = window.perf.key_order;
}
this._render();
this.bugSpinner = this.querySelector('#bugSpinner');
@@ -481,10 +480,10 @@
}
this._config = val;
if (this._config.interesting === 0) {
- this._config.interesting = window.sk?.perf?.interesting || 0;
+ this._config.interesting = window.perf?.interesting || 0;
}
if (this._config.radius === 0) {
- this._config.radius = window.sk?.perf?.radius || 0;
+ this._config.radius = window.perf?.radius || 0;
}
this._render();
}
diff --git a/perf/modules/alert-config-sk/alert-config-sk_puppeteer_test.ts b/perf/modules/alert-config-sk/alert-config-sk_puppeteer_test.ts
index dbb9d65..15c01a5 100644
--- a/perf/modules/alert-config-sk/alert-config-sk_puppeteer_test.ts
+++ b/perf/modules/alert-config-sk/alert-config-sk_puppeteer_test.ts
@@ -23,7 +23,7 @@
it('shows the default view', async () => {
await takeScreenshot(testBed.page, 'perf', 'alert-config-sk');
});
- it('does not show group_by if window.sk.perf.display_group_by is false', async () => {
+ it('does not show group_by if window.perf.display_group_by is false', async () => {
await testBed.page.click('#hide_group_by');
await takeScreenshot(testBed.page, 'perf', 'alert-config-sk-no-group-by');
});
diff --git a/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk-demo.ts b/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk-demo.ts
index ef49603..c76bec8 100644
--- a/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk-demo.ts
+++ b/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk-demo.ts
@@ -94,7 +94,6 @@
);
});
-window.sk = window.sk || {};
-window.sk.perf = window.sk.perf || {};
-window.sk.perf.key_order = [];
-window.sk.perf.demo = true;
+window.perf = window.perf || {};
+window.perf.key_order = [];
+window.perf.demo = true;
diff --git a/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk.ts b/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk.ts
index f85b2f1..b641e15 100644
--- a/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk.ts
+++ b/perf/modules/cluster-lastn-page-sk/cluster-lastn-page-sk.ts
@@ -86,7 +86,7 @@
constructor() {
super(ClusterLastNPageSk.template);
- if (window.sk.perf.demo) {
+ if (window.perf.demo) {
this.domain.end = Math.floor(new Date(2020, 4, 1).valueOf() / 1000);
}
}
@@ -96,7 +96,7 @@
<alert-config-sk
.config=${ele.state}
.paramset=${ele.paramset}
- .key_order=${window.sk.perf.key_order}
+ .key_order=${window.perf.key_order}
></alert-config-sk>
<div class="buttons">
<button @click=${ele.alertClose}>Cancel</button>
diff --git a/perf/modules/cluster-page-sk/cluster-page-sk-demo.ts b/perf/modules/cluster-page-sk/cluster-page-sk-demo.ts
index 0cdeda7..ca06f36 100644
--- a/perf/modules/cluster-page-sk/cluster-page-sk-demo.ts
+++ b/perf/modules/cluster-page-sk/cluster-page-sk-demo.ts
@@ -113,15 +113,13 @@
);
});
-window.sk = {
- perf: {
- commit_range_url: '',
- key_order: ['config'],
- demo: true,
- radius: 7,
- num_shift: 10,
- interesting: 25,
- step_up_only: false,
- display_group_by: true,
- },
+window.perf = {
+ commit_range_url: '',
+ key_order: ['config'],
+ demo: true,
+ radius: 7,
+ num_shift: 10,
+ interesting: 25,
+ step_up_only: false,
+ display_group_by: true,
};
diff --git a/perf/modules/cluster-page-sk/cluster-page-sk.ts b/perf/modules/cluster-page-sk/cluster-page-sk.ts
index 6c182f1..532e4af 100644
--- a/perf/modules/cluster-page-sk/cluster-page-sk.ts
+++ b/perf/modules/cluster-page-sk/cluster-page-sk.ts
@@ -52,7 +52,7 @@
offset: number = -1;
- radius: number = window.sk.perf.radius;
+ radius: number = window.perf.radius;
query: string = '';
@@ -60,12 +60,12 @@
algo: ClusterAlgo = 'kmeans';
- interesting: number = window.sk.perf.interesting;
+ interesting: number = window.perf.interesting;
sparse: boolean = false;
constructor() {
- if (window.sk.perf.demo) {
+ if (window.perf.demo) {
this.begin = Math.floor(new Date(2020, 4, 1).valueOf() / 1000);
this.end = Math.floor(new Date(2020, 5, 1).valueOf() / 1000);
}
@@ -119,7 +119,7 @@
<div class="query-action">
<query-sk
@query-change=${ele.queryChanged}
- .key_order=${window.sk.perf.key_order}
+ .key_order=${window.perf.key_order}
.paramset=${ele.paramset}
current_query=${ele.state.query}
></query-sk>
@@ -364,7 +364,7 @@
});
},
);
- } catch (error) {
+ } catch (error: any) {
this.catch(error);
} finally {
this.requestId = '';
diff --git a/perf/modules/cluster-summary2-sk/cluster-summary2-sk-demo.html b/perf/modules/cluster-summary2-sk/cluster-summary2-sk-demo.html
index 303a8d5..5e02660 100644
--- a/perf/modules/cluster-summary2-sk/cluster-summary2-sk-demo.html
+++ b/perf/modules/cluster-summary2-sk/cluster-summary2-sk-demo.html
@@ -7,8 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript" charset="utf-8">
var sk = {};
- sk.perf = {};
- sk.perf.commit_range_url = '';
+ window.perf = {};
+ window.perf.commit_range_url = '';
</script>
<style type="text/css" media="screen">
cluster-summary2-sk {
diff --git a/perf/modules/cluster-summary2-sk/cluster-summary2-sk.ts b/perf/modules/cluster-summary2-sk/cluster-summary2-sk.ts
index d4a526d..edf96e8 100644
--- a/perf/modules/cluster-summary2-sk/cluster-summary2-sk.ts
+++ b/perf/modules/cluster-summary2-sk/cluster-summary2-sk.ts
@@ -437,7 +437,7 @@
}
// Populate rangelink.
- if (window.sk.perf.commit_range_url !== '') {
+ if (window.perf.commit_range_url !== '') {
// First find the commit at step_fit, and the next previous commit that has data.
let prevCommit = xbar - 1;
while (prevCommit > 0 && this.summary!.centroid![prevCommit] === 1e32) {
@@ -451,7 +451,7 @@
ClusterSummary2Sk.lookupCids(cids)
.then((json: CIDHandlerResponse) => {
// Create the URL.
- let url = window.sk.perf.commit_range_url;
+ let url = window.perf.commit_range_url;
url = url.replace('{begin}', json.commitSlice![0].hash);
url = url.replace('{end}', json.commitSlice![1].hash);
// Now populate link, including text and href.
diff --git a/perf/modules/domain-picker-sk/domain-picker-sk.ts b/perf/modules/domain-picker-sk/domain-picker-sk.ts
index 8f01e8d..28a9408 100644
--- a/perf/modules/domain-picker-sk/domain-picker-sk.ts
+++ b/perf/modules/domain-picker-sk/domain-picker-sk.ts
@@ -119,7 +119,7 @@
<input
@change=${ele.numChanged}
type="number"
- .value="${ele._state.num_commits}"
+ .value="${ele._state.num_commits.toString()}"
min="1"
max="5000"
list="defaultNumbers"
diff --git a/perf/modules/explore-sk/explore-sk.ts b/perf/modules/explore-sk/explore-sk.ts
index 7a1fe06..8f216ed 100644
--- a/perf/modules/explore-sk/explore-sk.ts
+++ b/perf/modules/explore-sk/explore-sk.ts
@@ -305,7 +305,7 @@
// is no pending request.
private _requestId = '';
- private _numShift = window.sk.perf.num_shift;
+ private _numShift = window.perf.num_shift;
// The id of the interval timer if we are refreshing.
private _refreshId = -1;
@@ -652,7 +652,7 @@
request_type: this.state.requestType,
};
- this.query!.key_order = window.sk.perf.key_order || [];
+ this.query!.key_order = window.perf.key_order || [];
this.query!.paramset = json.dataframe.paramset;
this.pivotControl!.paramset = json.dataframe.paramset;
diff --git a/perf/modules/explore-sk/explore-sk_test.ts b/perf/modules/explore-sk/explore-sk_test.ts
index 8802e66..ff78217 100644
--- a/perf/modules/explore-sk/explore-sk_test.ts
+++ b/perf/modules/explore-sk/explore-sk_test.ts
@@ -70,17 +70,16 @@
});
describe('applyFuncToTraces', () => {
- window.sk = {
- perf: {
- radius: 2,
- key_order: null,
- num_shift: 50,
- interesting: 2,
- step_up_only: false,
- commit_range_url: '',
- demo: true,
- display_group_by: false,
- },
+ window.perf = {
+ radius: 2,
+ key_order: null,
+ num_shift: 50,
+ interesting: 2,
+ step_up_only: false,
+ commit_range_url: '',
+ demo: true,
+ display_group_by: false,
+
};
// Create a common element-sk to be used by all the tests.
diff --git a/perf/modules/trybot-page-sk/trybot-page-sk-demo.ts b/perf/modules/trybot-page-sk/trybot-page-sk-demo.ts
index 95f12d9..b16b3dd 100644
--- a/perf/modules/trybot-page-sk/trybot-page-sk-demo.ts
+++ b/perf/modules/trybot-page-sk/trybot-page-sk-demo.ts
@@ -6,19 +6,15 @@
import { CommitDetailPickerSk } from '../commit-detail-picker-sk/commit-detail-picker-sk';
import { QuerySk } from '../../../infra-sk/modules/query-sk/query-sk';
-import { TrybotPageSk } from './trybot-page-sk';
-
-window.sk = {
- perf: {
- commit_range_url: '',
- key_order: ['config'],
- demo: true,
- radius: 7,
- num_shift: 10,
- interesting: 25,
- step_up_only: false,
- display_group_by: true,
- },
+window.perf = {
+ commit_range_url: '',
+ key_order: ['config'],
+ demo: true,
+ radius: 7,
+ num_shift: 10,
+ interesting: 25,
+ step_up_only: false,
+ display_group_by: true,
};
Date.now = () => Date.parse('2020-03-22T00:00:00.000Z');
diff --git a/perf/modules/trybot-page-sk/trybot-page-sk.ts b/perf/modules/trybot-page-sk/trybot-page-sk.ts
index ffd1b31..76ff8ea 100644
--- a/perf/modules/trybot-page-sk/trybot-page-sk.ts
+++ b/perf/modules/trybot-page-sk/trybot-page-sk.ts
@@ -289,7 +289,7 @@
super.connectedCallback();
this._render();
this.query = this.querySelector('#query');
- this.query!.key_order = window.sk.perf.key_order || [];
+ this.query!.key_order = window.perf.key_order || [];
this.queryCount = this.querySelector('#query-count');
this.spinner = this.querySelector('#run-spinner');
this.individualPlot = this.querySelector('#individual-plot');
@@ -309,7 +309,7 @@
// From this point on reflect the state to the URL.
this.startStateReflector();
- } catch (error) {
+ } catch (error: any) {
errorMessage(error);
}
}
@@ -328,7 +328,7 @@
} else {
throw new Error(messagesToErrorString(prog.messages));
}
- } catch (error) {
+ } catch (error: any) {
errorMessage(error, 0);
}
}
diff --git a/perf/modules/window/window.ts b/perf/modules/window/window.ts
index f4bccf2..1d8df90 100644
--- a/perf/modules/window/window.ts
+++ b/perf/modules/window/window.ts
@@ -2,9 +2,7 @@
import { SkPerfConfig } from '../json';
declare global {
- interface Window {
- sk: {
- perf: SkPerfConfig;
- };
- }
+ interface Window {
+ perf: SkPerfConfig;
}
+}
diff --git a/perf/pages/alerts.html b/perf/pages/alerts.html
index 1a2b9d9..91fbcdb 100644
--- a/perf/pages/alerts.html
+++ b/perf/pages/alerts.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring - Alerts</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />
diff --git a/perf/pages/clusters2.html b/perf/pages/clusters2.html
index 4e5678f..775e3b8 100644
--- a/perf/pages/clusters2.html
+++ b/perf/pages/clusters2.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />
diff --git a/perf/pages/dryrunalert.html b/perf/pages/dryrunalert.html
index 97f793d..1ca3ad3 100644
--- a/perf/pages/dryrunalert.html
+++ b/perf/pages/dryrunalert.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />
diff --git a/perf/pages/newindex.html b/perf/pages/newindex.html
index b98d89a..17e060b 100644
--- a/perf/pages/newindex.html
+++ b/perf/pages/newindex.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />
diff --git a/perf/pages/triage.html b/perf/pages/triage.html
index 6d24c1a..06a5409 100644
--- a/perf/pages/triage.html
+++ b/perf/pages/triage.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />
diff --git a/perf/pages/trybot.html b/perf/pages/trybot.html
index ce3d2bf..6aa9bf7 100644
--- a/perf/pages/trybot.html
+++ b/perf/pages/trybot.html
@@ -3,8 +3,7 @@
<head>
<title>Skia Performance Monitoring</title>
<script type="text/javascript" charset="utf-8">
- this.sk = this.sk || {};
- this.sk.perf = {{.context }};
+ this.perf = {{.context }};
</script>
<meta charset="utf-8" />
<meta name="theme-color" content="#1f78b4" />