Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions benchmarks/benchmarks/traj_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
except ImportError:
pass

try:
import MDAnalysis as mda

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from MDAnalysis.coordinates.PDB.PDBReader

from MDAnalysisTests.datafiles import PDB_multiframe
except ImportError:
pass

traj_dict = {
"XTC": [XTC, XTCReader],
"TRR": [TRR, TRRReader],
Expand Down Expand Up @@ -71,3 +77,20 @@ def time_strides(self, traj_format):
"""
for ts in self.reader_object:
pass


class PDBReaderBench(object):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to create a separate class? Did you try adding coordinates.PDB.PDBReader and PDB_multiframe in the traj_dict and then handling it through the params?

"""Benchmarks for PDB file format reading and parsing"""

units = "ms"
timeout = 60.0

def setup(self):
self.u = mda.Universe(PDB_multiframe)

def time_read(self):
mda.Universe(PDB_multiframe)
Comment on lines +91 to +92

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This includes time for both topology and setting up PDBReader.

You could try

PDBReader(PDB_multiframe, n_atoms=u.atoms.n_atoms)

By providing n_atoms you avoid parsing the PDB file inside the Reader (see

with PDBParser.PDBParser(self.filename) as p:
top = p.parse()
self.n_atoms = top.n_atoms
for the rather ugly code) and so you really only benchmark the actual setup.

You could benchmark the two cases: one with n_atoms, the other without.


def time_iterate(self):
for ts in self.u.trajectory:
pass
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The rules for this file:
* 2.11.0

Fixes
* Added ASV benchmark for PDB trajectory reading (PR #1234)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be an enhancement, not a fix.

* `MDAnalysis.analysis.nucleicacids.WatsonCrickDist`, `MinorPairDist`,
and `MajorPairDist` now match residue names against the full resname
instead of only the first character, fixing incorrect behaviour with
Expand Down
Loading