-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add performance unit test for timeline-chart
This commit adds unit tests that measure the performance of the bottlenecks of the timeline chart while zooming in. With these unit tests, developers now can measure the effects of their patches on the performance of the timeline chart. Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
- Loading branch information
1 parent
5d40c37
commit e69ac71
Showing
21 changed files
with
1,875,608 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
timeline-chart/src/layer/__tests__/time-graph-chart-long-removal-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import { TimeGraphPerformanceTest } from "../unitTest/time-graph-performance-test"; | ||
import { LongRemovalTestData } from '../unitTest/data/longRemoval/settings'; | ||
|
||
describe('TImeGraphChart performance test with long states removal', () => { | ||
let timeGraph: TimeGraphPerformanceTest; | ||
|
||
beforeEach(() => { | ||
// Initiating the test | ||
timeGraph = new TimeGraphPerformanceTest( | ||
LongRemovalTestData.data, | ||
LongRemovalTestData.viewRange); | ||
|
||
timeGraph.toNextDataSet(); | ||
timeGraph.setViewRange(LongRemovalTestData.zoomRange.start, LongRemovalTestData.zoomRange.end); | ||
}); | ||
|
||
it ('addOrUpdateRow() test with long removal time', () => { | ||
const data = timeGraph.getData(); | ||
const timeGraphChart = timeGraph.getTimeGraphChart(); | ||
|
||
const start = performance.now(); | ||
// @ts-ignore | ||
timeGraphChart.addOrUpdateRows(data); | ||
const end = performance.now(); | ||
const time = end - start; | ||
console.log("addOrUpdateRow() - with long removal time", time, "ms"); | ||
expect(time).toBeGreaterThan(0); | ||
}) | ||
}) |
44 changes: 44 additions & 0 deletions
44
timeline-chart/src/layer/__tests__/time-graph-chart-with-labels.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import { TimeGraphPerformanceTest } from "../unitTest/time-graph-performance-test"; | ||
import { WithLabelTestData } from "../unitTest/data/withLabels/settings"; | ||
|
||
describe('TImeGraphChart performance test with labels', () => { | ||
let timeGraph: TimeGraphPerformanceTest; | ||
|
||
beforeEach(() => { | ||
// Initiating the test | ||
timeGraph = new TimeGraphPerformanceTest( | ||
WithLabelTestData.data, | ||
WithLabelTestData.viewRange); | ||
|
||
}); | ||
|
||
it ('onScaleFactorChanged test', () => { | ||
// Making sure that the set up is good | ||
expect(timeGraph.getAbsoluteStart()).toEqual(WithLabelTestData.traceStart); | ||
expect(timeGraph.getTotalLength()).toEqual(WithLabelTestData.totalLength); | ||
|
||
// Set the zoom range so that we don't have to call adjustZoom() | ||
const start = performance.now(); | ||
timeGraph.scaleChart(1.2); | ||
const end = performance.now(); | ||
const time = end - start; | ||
console.log("onScaleFactorChanged - with labels running time", time, "ms"); | ||
expect(time).toBeGreaterThan(0); | ||
}) | ||
|
||
it ('addOrUpdateRow() test', () => { | ||
const timeGraphChart = timeGraph.getTimeGraphChart(); | ||
const data = timeGraph.getData(); | ||
|
||
const start = performance.now(); | ||
// We don't need to fetch any new data at all, the function should wipe out all existing rows | ||
// and rerender them. | ||
// @ts-ignore | ||
timeGraphChart.addOrUpdateRows(data); | ||
const end = performance.now(); | ||
const time = end - start; | ||
console.log("addOrUpdateRow() - with labels running time", time, "ms"); | ||
expect(time).toBeGreaterThan(0); | ||
}) | ||
}) |
39 changes: 39 additions & 0 deletions
39
timeline-chart/src/layer/__tests__/time-graph-chart-without-labels.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
import { TimeGraphPerformanceTest } from "../unitTest/time-graph-performance-test"; | ||
import { NoLabelTestData } from "../unitTest/data/noLabels/settings"; | ||
|
||
describe('TImeGraphChart performance test without labels', () => { | ||
let timeGraph: TimeGraphPerformanceTest; | ||
|
||
beforeEach(() => { | ||
// Initiating the test | ||
timeGraph = new TimeGraphPerformanceTest( | ||
NoLabelTestData.data, | ||
NoLabelTestData.viewRange); | ||
}); | ||
|
||
it ('onScaleFactorChanged test', () => { | ||
const start = performance.now(); | ||
// Set the view range so that the on view range handlers are triggered | ||
timeGraph.scaleChart(1.2); // Zoom in | ||
const end = performance.now(); | ||
const time = end - start; | ||
console.log("onScaleFactorChanged - without labels running time", time, "ms"); | ||
expect(time).toBeGreaterThan(0); | ||
}) | ||
|
||
it ('addOrUpdateRow() test', () => { | ||
const timeGraphChart = timeGraph.getTimeGraphChart(); | ||
const data = timeGraph.getData(); | ||
|
||
const start = performance.now(); | ||
// We don't need to fetch any new data at all, the function should wipe out all existing rows | ||
// and rerender them. | ||
// @ts-ignore | ||
timeGraphChart.addOrUpdateRows(data); | ||
const end = performance.now(); | ||
const time = end - start; | ||
console.log("addOrUpdateRow() - without labels running time", time, "ms"); | ||
expect(time).toBeGreaterThan(0); | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
timeline-chart/src/layer/unitTest/data/longRemoval/settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { timeGraphEntries } from "./test-entries"; | ||
import { timeGraphRowIds } from "./test-ids"; | ||
import { timeGraphStates } from "./test-states"; | ||
import { timeGraphStates2 } from "./test-states-2"; | ||
|
||
export const LongRemovalTestData = { | ||
traceStart: BigInt("1673902683695025022"), | ||
totalLength: BigInt("3027146240"), | ||
// The view range to set the time graph chart to before the zoom in absolute value | ||
viewRange: { | ||
start: BigInt("1673902684100000000") - BigInt("1673902683695025022"), | ||
end: BigInt("1673902684200000000") - BigInt("1673902683695025022") | ||
}, | ||
// The view range post zooming is applied, logical time | ||
zoomRange: { | ||
start: BigInt("414974978"), | ||
end: BigInt("424974978") | ||
}, | ||
data: [ | ||
{ | ||
timeGraphEntries: timeGraphEntries, | ||
timeGraphRowIds: timeGraphRowIds, | ||
timeGraphStates: timeGraphStates | ||
}, | ||
{ | ||
timeGraphEntries: timeGraphEntries, | ||
timeGraphRowIds: timeGraphRowIds, | ||
timeGraphStates: timeGraphStates2 | ||
} | ||
] | ||
} |
Oops, something went wrong.