-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(debug): Add timing information about time to first image/all ima…
…ges, and query time (#3681)
- Loading branch information
1 parent
1b207f1
commit 108383b
Showing
10 changed files
with
125 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { log, Types } from '@ohif/core'; | ||
import { EVENTS } from '@cornerstonejs/core'; | ||
|
||
const { TimingEnum } = Types; | ||
|
||
const IMAGE_TIMING_KEYS = [ | ||
TimingEnum.DISPLAY_SETS_TO_ALL_IMAGES, | ||
TimingEnum.DISPLAY_SETS_TO_FIRST_IMAGE, | ||
TimingEnum.STUDY_TO_FIRST_IMAGE, | ||
]; | ||
|
||
const imageTiming = { | ||
viewportsWaiting: 0, | ||
}; | ||
|
||
/** | ||
* Defines the initial view timing reporting. | ||
* This allows knowing how many viewports are waiting for initial views and | ||
* when the IMAGE_RENDERED gets sent out. | ||
* The first image rendered will fire the FIRST_IMAGE timeEnd logs, while | ||
* the last of the enabled viewport will fire the ALL_IMAGES timeEnd logs. | ||
* | ||
*/ | ||
|
||
export default function initViewTiming({ element }) { | ||
if (!IMAGE_TIMING_KEYS.find(key => log.timingKeys[key])) { | ||
return; | ||
} | ||
imageTiming.viewportsWaiting += 1; | ||
element.addEventListener(EVENTS.IMAGE_RENDERED, imageRenderedListener); | ||
} | ||
|
||
function imageRenderedListener(evt) { | ||
if (evt.detail.viewportStatus === 'preRender') { | ||
return; | ||
} | ||
log.timeEnd(TimingEnum.DISPLAY_SETS_TO_FIRST_IMAGE); | ||
log.timeEnd(TimingEnum.STUDY_TO_FIRST_IMAGE); | ||
log.timeEnd(TimingEnum.SCRIPT_TO_VIEW); | ||
imageTiming.viewportsWaiting -= 1; | ||
evt.detail.element.removeEventListener(EVENTS.IMAGE_RENDERED, imageRenderedListener); | ||
if (!imageTiming.viewportsWaiting) { | ||
log.timeEnd(TimingEnum.DISPLAY_SETS_TO_ALL_IMAGES); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export enum TimingEnum { | ||
// The time from when the users selects a study until the study metadata | ||
// is loaded (and the display sets are ready) | ||
STUDY_TO_DISPLAY_SETS = 'studyToDisplaySetsLoaded', | ||
|
||
// The time from when the user selects a study until any viewport renders | ||
STUDY_TO_FIRST_IMAGE = 'studyToFirstImage', | ||
|
||
// The time from when display sets are loaded until any viewport renders | ||
// an image. | ||
DISPLAY_SETS_TO_FIRST_IMAGE = 'displaySetsToFirstImage', | ||
|
||
// The time from when display sets are loaded until all viewports have images | ||
DISPLAY_SETS_TO_ALL_IMAGES = 'displaySetsToAllImages', | ||
|
||
// The time from when the user hits search until the worklist is displayed | ||
SEARCH_TO_LIST = 'searchToList', | ||
|
||
// The time from when the html script first starts being evaluated (before | ||
// any other scripts or CSS is loaded), until the time that the first image | ||
// is viewed for viewer endpoints, or the time that the first search for studies | ||
// completes. | ||
SCRIPT_TO_VIEW = 'scriptToView', | ||
} |
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