From fa1cca1d862db0a4792c4e2b52cb17b90fc59c00 Mon Sep 17 00:00:00 2001 From: Syed Pasha Date: Thu, 5 Oct 2023 00:44:20 +0530 Subject: [PATCH] initial commit for viewer benchmarks --- src/imageLoader/wadouri/loadImage.js | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/imageLoader/wadouri/loadImage.js b/src/imageLoader/wadouri/loadImage.js index f077b3c8..68bf5edc 100644 --- a/src/imageLoader/wadouri/loadImage.js +++ b/src/imageLoader/wadouri/loadImage.js @@ -15,6 +15,31 @@ function addDecache(imageLoadObject, imageId) { }; } +window.store = {}; + +function updateTime(imageId, time) { + const SeriesInstanceUID = getSeriesInstanceUIDFromImageId(imageId); + + if (!window.store[SeriesInstanceUID]) { + window.store[SeriesInstanceUID] = {}; + } + + if (!window.store[SeriesInstanceUID][imageId]) { + window.store[SeriesInstanceUID][imageId] = [time]; + } else { + window.store[SeriesInstanceUID][imageId].push(time); + } +} + +function getSeriesInstanceUIDFromImageId(imageId) { + const [, imageIdWithNoDicomWeb] = imageId.split('dicomweb:'); + const url = new URL(imageIdWithNoDicomWeb); + const { pathname } = url; + const [emptyString, userId, SeriesInstanceUID] = pathname.split('/'); + + return SeriesInstanceUID; +} + function loadImageFromPromise( dataSetPromise, imageId, @@ -28,6 +53,10 @@ function loadImageFromPromise( cancelFn: undefined, }; + const startTime = performance.now(); + + updateTime(imageId, startTime); + imageLoadObject.promise = new Promise((resolve, reject) => { dataSetPromise.then( (dataSet /* , xhr*/) => { @@ -58,6 +87,10 @@ function loadImageFromPromise( callbacks.imageDoneCallback(image); } resolve(image); + + const endTime = performance.now(); + + updateTime(imageId, endTime); }, function (error) { // Reject the error, and the dataSet