diff options
Diffstat (limited to 'ui/src/tracks/cpu_profile/index.ts')
-rw-r--r-- | ui/src/tracks/cpu_profile/index.ts | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/ui/src/tracks/cpu_profile/index.ts b/ui/src/tracks/cpu_profile/index.ts index eee7b17fc..028d5b112 100644 --- a/ui/src/tracks/cpu_profile/index.ts +++ b/ui/src/tracks/cpu_profile/index.ts @@ -18,7 +18,7 @@ import {Actions} from '../../common/actions'; import {hslForSlice} from '../../common/colorizer'; import {PluginContext} from '../../common/plugin_api'; import {NUM} from '../../common/query_result'; -import {fromNs, toNs} from '../../common/time'; +import {fromNs, TPDuration, TPTime} from '../../common/time'; import {TrackData} from '../../common/track_data'; import { TrackController, @@ -46,7 +46,7 @@ export interface Config { class CpuProfileTrackController extends TrackController<Config, Data> { static readonly kind = CPU_PROFILE_TRACK_KIND; - async onBoundsChange(start: number, end: number, resolution: number): + async onBoundsChange(start: TPTime, end: TPTime, resolution: TPDuration): Promise<Data> { const query = `select id, @@ -105,7 +105,7 @@ class CpuProfileTrack extends Track<Config, Data> { renderCanvas(ctx: CanvasRenderingContext2D): void { const { - timeScale, + visibleTimeScale: timeScale, } = globals.frontendLocalState; const data = this.data(); @@ -120,7 +120,7 @@ class CpuProfileTrack extends Track<Config, Data> { const strokeWidth = isSelected ? 3 : 0; this.drawMarker( ctx, - timeScale.timeToPx(fromNs(centerX)), + timeScale.secondsToPx(fromNs(centerX)), this.centerY, isHovered, strokeWidth, @@ -146,8 +146,8 @@ class CpuProfileTrack extends Track<Config, Data> { if (clusterStartIndex !== clusterEndIndex) { const startX = data.tsStarts[clusterStartIndex]; const endX = data.tsStarts[clusterEndIndex]; - const leftPx = timeScale.timeToPx(fromNs(startX)) - this.markerWidth; - const rightPx = timeScale.timeToPx(fromNs(endX)) + this.markerWidth; + const leftPx = timeScale.secondsToPx(fromNs(startX)) - this.markerWidth; + const rightPx = timeScale.secondsToPx(fromNs(endX)) + this.markerWidth; const width = rightPx - leftPx; ctx.fillStyle = colorForSample(callsiteId, false); ctx.fillRect(leftPx, MARGIN_TOP, width, BAR_HEIGHT); @@ -179,8 +179,10 @@ class CpuProfileTrack extends Track<Config, Data> { onMouseMove({x, y}: {x: number, y: number}) { const data = this.data(); if (data === undefined) return; - const {timeScale} = globals.frontendLocalState; - const time = toNs(timeScale.pxToTime(x)); + const { + visibleTimeScale: timeScale, + } = globals.frontendLocalState; + const time = timeScale.pxToHpTime(x).nanos; const [left, right] = searchSegment(data.tsStarts, time); const index = this.findTimestampIndex(left, timeScale, data, x, y, right); this.hoveredTs = index === -1 ? undefined : data.tsStarts[index]; @@ -193,9 +195,11 @@ class CpuProfileTrack extends Track<Config, Data> { onMouseClick({x, y}: {x: number, y: number}) { const data = this.data(); if (data === undefined) return false; - const {timeScale} = globals.frontendLocalState; + const { + visibleTimeScale: timeScale, + } = globals.frontendLocalState; - const time = toNs(timeScale.pxToTime(x)); + const time = timeScale.pxToHpTime(x).nanos; const [left, right] = searchSegment(data.tsStarts, time); const index = this.findTimestampIndex(left, timeScale, data, x, y, right); @@ -217,13 +221,13 @@ class CpuProfileTrack extends Track<Config, Data> { right: number): number { let index = -1; if (left !== -1) { - const centerX = timeScale.timeToPx(fromNs(data.tsStarts[left])); + const centerX = timeScale.secondsToPx(fromNs(data.tsStarts[left])); if (this.isInMarker(x, y, centerX)) { index = left; } } if (right !== -1) { - const centerX = timeScale.timeToPx(fromNs(data.tsStarts[right])); + const centerX = timeScale.secondsToPx(fromNs(data.tsStarts[right])); if (this.isInMarker(x, y, centerX)) { index = right; } |