Skip to content
This repository was archived by the owner on Apr 26, 2023. It is now read-only.
This repository was archived by the owner on Apr 26, 2023. It is now read-only.

recode time consuming loop in file protocol_particles.py #1857

Open
@rmarabini

Description

@rmarabini

In file protocol_particles.py the loop:

        for micKey, mic in micDict.iteritems():
            if counter % 50 == 0:
                b = datetime.now()
                print b-a, 'reading coordinates for mic number', "%06d" % counter
                sys.stdout.flush()  # force buffer to print
            counter += 1

            micId = mic.getObjId()
            coordList = []
            self.debug("Loading coords for mic: %s (%s)" % (micId, micKey))
            for coord in coordSet.iterItems(where='_micId=%s' % micId):
                # TODO: Check performance penalty of using this clone
                coordList.append(coord.clone())

is very inefficient should be rewritten as

         for coord in coordSet.iterItems(orderBy='_micId',
                                         direction='ASC'):
             micId = coord.getMicId()
             if micId != lastMicId:
                 lastMicId = micId
                 ..
             ..

If no indexes are used there are two orders of magnitude between both ways to write the code

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions