-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
200,066 additions
and
95 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,68 @@ | ||
import { Page } from "puppeteer"; | ||
|
||
import { Tests } from "../utils"; | ||
import { Test, Tests } from "../utils"; | ||
|
||
const tests: Tests = [ | ||
{ | ||
name: "n-renders-small-scene", | ||
scenario: async (page: Page): Promise<void> => { | ||
await page.evaluate(() => { | ||
const { | ||
data: { arctic }, | ||
Sigma, | ||
container, | ||
rafNTimes, | ||
} = dependencies; | ||
const TIMES = 20; | ||
|
||
new Sigma(arctic, container); | ||
const METHODS = ["refresh", "render"] as const; | ||
type Method = (typeof METHODS)[number]; | ||
|
||
return rafNTimes(() => { | ||
// This simulates a layout iteration, that triggers a full reindex of the graph: | ||
arctic.forEachNode((node) => arctic.mergeNodeAttributes(node, { x: Math.random(), y: Math.random() })); | ||
}, 20); | ||
}); | ||
}, | ||
}, | ||
{ | ||
name: "n-refreshes-small-scene", | ||
scenario: async (page: Page): Promise<void> => { | ||
await page.evaluate(() => { | ||
const { | ||
data: { arctic }, | ||
Sigma, | ||
container, | ||
rafNTimes, | ||
} = dependencies; | ||
const SIZES = ["small", "medium", "large"] as const; | ||
type Size = (typeof SIZES)[number]; | ||
|
||
const sigma = new Sigma(arctic, container); | ||
const camera = sigma.getCamera(); | ||
|
||
return rafNTimes(() => { | ||
// This simulates a user interaction, that triggers a render of the graph: | ||
camera.setState({ angle: camera.angle + 0.1 }); | ||
}, 20); | ||
}); | ||
}, | ||
}, | ||
{ | ||
name: "n-renders-large-scene", | ||
scenario: async (page: Page): Promise<void> => { | ||
await page.evaluate(() => { | ||
const { | ||
data: { arctic }, | ||
Sigma, | ||
container, | ||
rafNTimes, | ||
} = dependencies; | ||
const SCREEN_SIZES: Record<Size, number> = { | ||
small: 600, | ||
medium: 1600, | ||
large: 2600, | ||
}; | ||
const GRAPHS: Record<Size, string> = { | ||
small: "lesMiserables", | ||
medium: "arctic", | ||
large: "largeGraph", | ||
}; | ||
|
||
new Sigma(arctic, container); | ||
function getTest(method: Method, screenSize: Size, graphSize: Size): Test { | ||
const graphKey = GRAPHS[graphSize]; | ||
const screenKey = SCREEN_SIZES[screenSize]; | ||
|
||
return rafNTimes(() => { | ||
// This simulates a layout iteration, that triggers a full reindex of the graph: | ||
arctic.forEachNode((node) => arctic.mergeNodeAttributes(node, { x: Math.random(), y: Math.random() })); | ||
}, 20); | ||
}); | ||
}, | ||
dimensions: { | ||
width: 2600, | ||
height: 2600, | ||
}, | ||
}, | ||
{ | ||
name: "n-refreshes-large-scene", | ||
return { | ||
name: `${method}-${screenSize}-scene-${graphSize}-graph`, | ||
scenario: async (page: Page): Promise<void> => { | ||
await page.evaluate(() => { | ||
const { | ||
data: { arctic }, | ||
Sigma, | ||
container, | ||
rafNTimes, | ||
} = dependencies; | ||
await page.evaluate( | ||
(method: string, graphKey: string, times: number) => { | ||
const { data, Sigma, container, rafNTimes } = dependencies; | ||
|
||
const sigma = new Sigma(arctic, container); | ||
const camera = sigma.getCamera(); | ||
const graph = data[graphKey]; | ||
const sigma = new Sigma(graph, container); | ||
const camera = sigma.getCamera(); | ||
|
||
return rafNTimes(() => { | ||
// This simulates a user interaction, that triggers a render of the graph: | ||
camera.setState({ angle: camera.angle + 0.1 }); | ||
}, 20); | ||
}); | ||
switch (method) { | ||
case "refresh": | ||
return rafNTimes(() => { | ||
// This simulates a layout iteration, that triggers a full reindex of the graph: | ||
graph.forEachNode((node) => graph.mergeNodeAttributes(node, { x: Math.random(), y: Math.random() })); | ||
}, times); | ||
case "render": | ||
return rafNTimes(() => { | ||
// This simulates a user interaction, that triggers a render of the graph: | ||
camera.setState({ angle: camera.angle + 0.1 }); | ||
}, times); | ||
} | ||
}, | ||
method, | ||
graphKey, | ||
TIMES, | ||
); | ||
}, | ||
dimensions: { | ||
width: 2600, | ||
height: 2600, | ||
width: screenKey, | ||
height: screenKey, | ||
}, | ||
}, | ||
]; | ||
}; | ||
} | ||
|
||
const tests: Tests = METHODS.flatMap((method) => | ||
SIZES.flatMap((screenSize) => SIZES.map((graphSize) => getTest(method, screenSize, graphSize))), | ||
); | ||
|
||
export default tests; |
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
Oops, something went wrong.