-
-
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: Add timing information for various user related actions
- Loading branch information
1 parent
52da92f
commit 11cb76c
Showing
8 changed files
with
94 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export enum TimingEnum { | ||
STUDY_TO_DISPLAY_SETS = 'studyToDisplaySetsLoaded', | ||
STUDY_TO_FIRST_IMAGE = 'studyToFirstImage', | ||
DISPLAY_SETS_TO_FIRST_IMAGE = 'displaySetsToFirstImage', | ||
DISPLAY_SETS_TO_ALL_IMAGES = 'displaySetsToAllImages', | ||
SCRIPT_TO_VIEW = 'scriptToView', | ||
SEARCH_TO_LIST = 'searchToList', | ||
} |
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