/usr/lib/python2.7/dist-packages/dicom/test/performance/raw_convert_test.py is in python-dicom 0.9.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # raw_convert_test.py
"""Try reading a large RTSTRUCT file, profiling how much time it takes"""
# Copyright (c) 2012 Darcy Mason
# This file is part of pydicom, relased under an MIT license.
# See the file license.txt included with this distribution, also
# available at http://pydicom.googlecode.com
# EDIT THIS SECTION --------------------------
# to point to local temp directory
tempfile = "/tmp/pydicom_stats"
read_filename = r"/Users/darcy/hg/pydicom/source/dicom/testfiles/RStest.dcm"
write_filename = "/tmp/write_test.dcm"
import dicom
import cProfile
import pstats
def test_full_read(filename):
dataset = dicom.read_file(filename)
return dataset
def walkval(dataset, dataelem):
dataelem.value
def test_convert_from_raw(dataset):
# s = str(dataset)
dataset.walk(walkval)
def test_write_file(dataset, write_filename):
dataset.save_as(write_filename)
if __name__ == "__main__":
runs = ['ds=test_full_read(read_filename)',
'test_convert_from_raw(ds)',
'test_write_file(ds, write_filename)',
]
for testrun in runs:
cProfile.run(testrun, tempfile)
p = pstats.Stats(tempfile)
print("---------------")
print(testrun)
print("---------------")
p.strip_dirs().sort_stats('time').print_stats(12)
# Clear disk cache for next run?
# import sys
# if not on_windows:
# prompt= "Run purge command (linux/Mac OS X) to clear disk cache?(N):"
# answer = raw_input(prompt)
# if answer.lower() == "y":
# print "Running 'purge'. Please wait..."
# os.system("purge")
|