v8/tools/system-analyzer/log/timer.mjs
Camillo Bruni 6078cb5283 [tools][system-analyzer] Various improvements
- Parse the condensed source position info support for jitted code
- Add progress bar/circle to loader
- Use temporary Array instead of concatenated strings in escapeField to
  reduce gc pressure
- Use bound functions as event handlers in more places
- Various timeline legend fixes:
  - Fix columns alignment when duration is present
  - Use fixed width to avoid breaking the UI
  - Correctly show total/percents for 'All' and 'Selection' entries
  - Improve usability of filtering buttons: added tooltips and fixed
    redrawing on filtering

Bug: v8:10644
Change-Id: I1275b31b7b13a05d9d6283d3067c1032d2d4819c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3574544
Reviewed-by: Patrick Thier <pthier@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79897}
2022-04-08 19:46:22 +00:00

57 lines
1.2 KiB
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {formatDurationMicros} from '../helper.mjs';
import {LogEntry} from './log.mjs';
export class TimerLogEntry extends LogEntry {
constructor(type, startTime, endTime = -1) {
super(type, startTime);
this._endTime = endTime;
this.depth = 0;
}
end(time) {
if (this.isInitialized) throw new Error('Invalid timer change');
this._endTime = time;
}
get isInitialized() {
return this._endTime !== -1;
}
get startTime() {
return this._time;
}
get endTime() {
return this._endTime;
}
get duration() {
return Math.max(0, this._endTime - this._time);
}
covers(time) {
return this._time <= time && time <= this._endTime;
}
get toolTipDict() {
const dict = super.toolTipDict;
dict.startTime = formatDurationMicros(dict.startTime);
dict.endTime = formatDurationMicros(dict.endTime);
dict.duration = formatDurationMicros(dict.duration);
return dict;
}
static get propertyNames() {
return [
'type',
'startTime',
'endTime',
'duration',
];
}
}