Skip to content

Commit c3c66ea

Browse files
committed
Explicitly minimized lazy loading impact and added comments on it.
Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent 22ca9d8 commit c3c66ea

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

tests/unit/test_decoder_nvimgcodec.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,16 @@ def performance_test_nvimgcodec_decoder_against_defaults(
237237
except Exception:
238238
pass
239239

240+
is_loaded = False
240241
for path in get_test_dicoms(folder_path):
241242
try:
242243
ds_default = dcmread(path)
244+
245+
# Minimize lazy loading impact
246+
if not is_loaded:
247+
ds_default.pixel_array
248+
is_loaded = True
249+
243250
transfer_syntax = ds_default.file_meta.TransferSyntaxUID
244251
start = time.perf_counter()
245252
baseline_pixels = ds_default.pixel_array
@@ -263,9 +270,16 @@ def performance_test_nvimgcodec_decoder_against_defaults(
263270
register_as_decoder_plugin()
264271

265272
combined_perf = {}
273+
is_loaded = False
266274
for path, perf in files_tested_with_perf.items():
267275
try:
268276
ds_custom = dcmread(path)
277+
278+
# Minimize lazy loading impact
279+
if not is_loaded:
280+
ds_custom.pixel_array
281+
is_loaded = True
282+
269283
start = time.perf_counter()
270284
nv_pixels = ds_custom.pixel_array
271285
perf["nvimgcodec_execution_time"] = time.perf_counter() - start
@@ -286,8 +300,12 @@ def performance_test_nvimgcodec_decoder_against_defaults(
286300
print(
287301
"## nvimgcodec decoder performance against Pydicom default decoders\n"
288302
"Test data include all Pydicom test DICOM instances of supported transfer syntaxes\n"
289-
"**Note:** nvImgCodec is well suited for multi-frame image with batch decompression, "
290-
"but the Pydicom decoder runner invokes the decoders frame by frame."
303+
"**Note:**\n"
304+
" - nvImgCodec is well suited for multi-frame image with batch decompression, "
305+
"but the Pydicom decoder runner invokes the decoders frame by frame.\n"
306+
" - Lazy loading impact is minimized by loading the first applicable test file's pixel data "
307+
"twice and ignoring the first run execution time; as such the measurement for the first "
308+
"test file is skewed by potential cacheing"
291309
"\n\n"
292310
"| Transfer Syntax | Default Decoder Execution Time | nvimgcodec Decoder Execution Time | File Name |"
293311
"\n"

0 commit comments

Comments
 (0)