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 issue #115

Open
jhuguetn opened this issue Oct 21, 2019 · 0 comments
Open

Performance issue #115

jhuguetn opened this issue Oct 21, 2019 · 0 comments

Comments

@jhuguetn
Copy link
Contributor

Performance issue found when attempting to get a list of file labels of a Resource object.

Using EObject label() method generates a per-file new GET request to the whole list of resource files which -in my opinion- is highly redundant and rather slow when resource has lots of files (see test below).

Performance test with ASHS resource of ~790 files using label() method:

import timeit
code1 = """
import pyxnat
c = pyxnat.Interface(config='.pyxnat.cfg')
flist = c.select.experiment('ACME_E00001').resource('ASHS').files()
fnamelist = [f.label() for f in flist]
"""
elapsed_time = timeit.timeit(code1, number=10)/10
print(elapsed_time)

67.44406228000298

Same test using _urn private property (see here):

import timeit
code2 = """
import pyxnat
c = pyxnat.Interface(config='.pyxnat.cfg')
flist = c.select.experiment('ACME_E00001').resource('ASHS').files()
fnamelist = [f._urn for f in flist]
"""
elapsed_time = timeit.timeit(code2, number=10)/10
print(elapsed_time)

0.18539366999757476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant