aboutsummaryrefslogtreecommitdiff
path: root/ui/src/tracks/process_scheduling/frontend.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/tracks/process_scheduling/frontend.ts')
-rw-r--r--ui/src/tracks/process_scheduling/frontend.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/ui/src/tracks/process_scheduling/frontend.ts b/ui/src/tracks/process_scheduling/frontend.ts
index 78a0e86e7..f13e8a31d 100644
--- a/ui/src/tracks/process_scheduling/frontend.ts
+++ b/ui/src/tracks/process_scheduling/frontend.ts
@@ -31,8 +31,6 @@ import {
const MARGIN_TOP = 5;
const RECT_HEIGHT = 30;
-const TRACK_HEIGHT = MARGIN_TOP * 2 + RECT_HEIGHT;
-const SUMMARY_HEIGHT = TRACK_HEIGHT - MARGIN_TOP;
class ProcessSchedulingTrack extends Track<Config, Data> {
static readonly kind = PROCESS_SCHEDULING_TRACK_KIND;
@@ -47,22 +45,26 @@ class ProcessSchedulingTrack extends Track<Config, Data> {
super(trackState);
}
- getHeight(): number {
- return TRACK_HEIGHT;
- }
-
renderCanvas(ctx: CanvasRenderingContext2D): void {
// TODO: fonts and colors should come from the CSS and not hardcoded here.
const {timeScale, visibleWindowTime} = globals.frontendLocalState;
const data = this.data();
+ // If there aren't enough cached slices data in |data| request more to
+ // the controller.
+ const inRange = data !== undefined &&
+ (visibleWindowTime.start >= data.start &&
+ visibleWindowTime.end <= data.end);
+ if (!inRange || data === undefined ||
+ data.resolution !== globals.getCurResolution()) {
+ globals.requestTrackData(this.trackState.id);
+ }
if (data === undefined) return; // Can't possibly draw anything.
// If the cached trace slices don't fully cover the visible time range,
// show a gray rectangle with a "Loading..." label.
checkerboardExcept(
ctx,
- this.getHeight(),
timeScale.timeToPx(visibleWindowTime.start),
timeScale.timeToPx(visibleWindowTime.end),
timeScale.timeToPx(data.start),
@@ -78,7 +80,7 @@ class ProcessSchedulingTrack extends Track<Config, Data> {
renderSummary(ctx: CanvasRenderingContext2D, data: SummaryData): void {
const {timeScale, visibleWindowTime} = globals.frontendLocalState;
const startPx = Math.floor(timeScale.timeToPx(visibleWindowTime.start));
- const bottomY = TRACK_HEIGHT;
+ const bottomY = MARGIN_TOP + RECT_HEIGHT;
let lastX = startPx;
let lastY = bottomY;
@@ -94,7 +96,7 @@ class ProcessSchedulingTrack extends Track<Config, Data> {
lastX = Math.floor(timeScale.timeToPx(startTime));
ctx.lineTo(lastX, lastY);
- lastY = MARGIN_TOP + Math.round(SUMMARY_HEIGHT * (1 - utilization));
+ lastY = MARGIN_TOP + Math.round(RECT_HEIGHT * (1 - utilization));
ctx.lineTo(lastX, lastY);
}
ctx.lineTo(lastX, bottomY);
@@ -107,7 +109,7 @@ class ProcessSchedulingTrack extends Track<Config, Data> {
assertTrue(data.starts.length === data.ends.length);
assertTrue(data.starts.length === data.utids.length);
- const cpuTrackHeight = Math.floor(RECT_HEIGHT / data.maxCpu);
+ const cpuTrackHeight = Math.floor(RECT_HEIGHT / data.numCpus);
for (let i = 0; i < data.starts.length; i++) {
const tStart = data.starts[i];
@@ -181,7 +183,7 @@ class ProcessSchedulingTrack extends Track<Config, Data> {
return;
}
- const cpuTrackHeight = Math.floor(RECT_HEIGHT / data.maxCpu);
+ const cpuTrackHeight = Math.floor(RECT_HEIGHT / data.numCpus);
const cpu = Math.floor((y - MARGIN_TOP) / (cpuTrackHeight + 1));
const {timeScale} = globals.frontendLocalState;
const t = timeScale.pxToTime(x);