Skip to content

Commit

Permalink
startTime & endTime for perf vis
Browse files Browse the repository at this point in the history
  • Loading branch information
niespodd committed Jun 11, 2021
1 parent 79f0fef commit 9c21cd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/assets/index.feb49b7d.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
break-inside: avoid;
}
</style>
<script type="module" crossorigin src="assets/index.e17f1f40.js"></script>
<script type="module" crossorigin src="assets/index.feb49b7d.js"></script>
<link rel="modulepreload" href="assets/vendor.0d07671f.js">
<link rel="stylesheet" href="assets/index.f44316bf.css">
</head>
Expand Down
7 changes: 7 additions & 0 deletions tester/src/testers/ResourceTiming.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const TIMING_COLOR = {
const TimelineVisualisation = ({ data }) => {
const timelineWrapper = React.useRef(undefined);
const [svgDimensions, setSvgDimensions] = React.useState(undefined);
const [timings, setTimings] = React.useState({undefined});

React.useEffect(() => {
if (!timelineWrapper.current) return;
Expand All @@ -30,6 +31,11 @@ const TimelineVisualisation = ({ data }) => {
const maxW = Math.max(...data.map((d) => d.startTime + d.duration));
const W = maxW - minW;

setTimings({
startTime: minW,
endTime: maxW,
});

return data.map((e) => {
return {
x: ((e.startTime - minW)/W) * width,
Expand All @@ -42,6 +48,7 @@ const TimelineVisualisation = ({ data }) => {

return (
<div ref={timelineWrapper} style={{ marginTop: '8px' }}>
<Text mb={2}>Start time <Code>{timings.startTime}</Code>, end time <Code>{timings.endTime}</Code></Text>
{svgDimensions && normalizedData && (
<svg {...svgDimensions}>
<Group>
Expand Down

0 comments on commit 9c21cd8

Please sign in to comment.