Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance degradation reading and writing files #605

Closed
mrbean-bremen opened this issue Mar 21, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@mrbean-bremen
Copy link
Member

commented Mar 21, 2018

I did some measurements for reading and writing DICOM files with pydicom 0.9.9 and 1.0 using timeit under Windows.
I got a slower by about 60% performance for reading and writing files with many tags (actually a read-write-delete cycle, but vastly dominated by writing) for the 1.0 version.

For reference (under Python 3.6), with a standard CT file with about 4400 private tags:

> pip install pydicom==0.9.9
> python -m timeit "import dicom;dicom.read_file('test.dcm')"
1000 loops, best of 3: 1.63 msec per loop

> python -m timeit "import dicom;import os;fs=dicom.read_file('test.dcm');dicom.write_file('t.dcm', fs);os.remove('t.dcm')"
10 loops, best of 3: 306 msec per loop

> pip install pydicom==1.0.2
> python -m timeit "import pydicom;dicom.read_file('test.dcm')"
100 loops, best of 3: 2.53 msec per loop

> python -m timeit "import pydicom;import os;fs=pydicom.read_file('test.dcm');pydicom.write_file('t.dcm', fs);os.remove('t.dcm')"
10 loops, best of 3: 520 msec per loop

Under Python 2.7 writing was slightly slower in both versions, but the difference was about the same.

With the same test file without the private tags (about 130 tags overall), reading took 1.6 vs. 1.8 msec, writing took 13.6 vs. 26.6 msec.

mrbean-bremen added a commit to mrbean-bremen/pydicom that referenced this issue Mar 22, 2018

darcymason added a commit that referenced this issue Mar 24, 2018

Added check for BaseTag in Tag() to avoid costly checks (#606)
* Added check for BaseTag in Tag() to avoid costly checks

- see #605

* Minor changes that improve reading performance

- use BaseTag for frequent comparisons (SpecificCharacterSet) to avoid calling Tag()
- sped up BaseTag.__eq__ for comparison with int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.