[ 
https://issues.apache.org/jira/browse/QPID-3378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yang XU updated QPID-3378:
--------------------------

    Attachment: PossiblePatch.py

supposed fixing way

> QPID python client API, bad performance about RangedSet.add 
> ------------------------------------------------------------
>
>                 Key: QPID-3378
>                 URL: https://issues.apache.org/jira/browse/QPID-3378
>             Project: Qpid
>          Issue Type: Improvement
>          Components: Python Client
>    Affects Versions: 0.6, 0.8, 0.10
>         Environment: winxp; intel E7500; 2G
>            Reporter: Yang XU
>            Priority: Minor
>              Labels: patch
>             Fix For: Future
>
>         Attachments: PossiblePatch.py, test.py
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> To feedback to server the mesages that client had been received, client 
> should use:
> >>> session.message_accept(Range)
> while the Range is a qpid.datatypes.RangedSet object. My test shows that it 
> has a bad performance when we want to feedback a batch at one time, test code 
> as attachment.
> Compring to the original RangedSet.add, the function enhanceadd could have a 
> much better performance. Also, in enhanceadd situation, some code in original 
> RangedSet are useless as following:
> ----------------------------------code------------
>   def add_range(self, range):
>     idx = 0
>     while idx < len(self.ranges):
>       r = self.ranges[idx]
>       if range.touches(r):
>         del self.ranges[idx]
>         range = range.span(r)
>       elif range.upper < r.lower:
>         self.ranges.insert(idx, range)
>         return
>       else:
>         idx += 1
>     self.ranges.append(range)
>   def add(self, lower, upper = None):
>     self.add_range(Range(lower, upper))
> ----------------------------------code------------
> it can be changed like with a further improvment:
> ----------------------------------code------------
> def add(self, lower, upper = None):
>     self.ranges.append((Range(lower, upper))
> ----------------------------------code------------
> The comparing result on my computer:
> --withou code changing
> ordered, unique
> old time used:  [0.030543205640406971]
> new time used:  [0.000312459202400521]
> disordered, unique
> old time used:  [6.1625172448676198]
> new time used:  [0.00031574488299845882]
> disordered, duplicated
> old time used:  [6.8560797353410585]
> new time used:  [1.6444935113447237]
> --with code changing(original way will not work, so the result is not listed)
> ordered, unique
> new time used:  [0.00029485411974586751]
> disordered, unique
> new time used:  [0.00029566614149547331]
> disordered, duplicated
> new time used:  [0.0015168716657040435]
> The possible patch code as attachment "PossiblePatch.py"

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to