[MERGE] rand_chars() optimization

Dmitry Vasiliev dima at hlabs.spb.ru
Sun Mar 11 18:21:38 GMT 2007


John Arbash Meinel wrote:
> Can you tune the number of loops to shoot for around 1s?

Done in the attached version.

> Oh, and we should add a small comment to let us know that it was
> actually benchmarked with different methods, and this was the fastest.
> That helps keep people from wondering if it should be done a different way.

Also done.

> On my machine, it is
> original	8421ms
> for loop	7200ms
> list comp	6916ms
> 
> Now, these are with rand_chars(16).

On my system with rand_chars(16)/100000:

Version with generator comprehension: 1937 ms
The original code: 1750 ms
Version with list comprehension: 1171 ms
The current version with 'for' loop: 1140 ms

> I'm generally positive about this change. Though I'm curious if you were
> seeing rand_chars() being a measurable overhead. It isn't something that
> we call a lot. (We call it once per invocation, regardless of the number
> of files, and then another time for revision ids).
> 
> I'm happy to have fast functions, just curious what you saw here.

Actually it was just code inspection result: I looked at the code and 
found the function which could be easily optimized so I just did it. :-)

-- 
Dmitry Vasiliev <dima at hlabs.spb.ru>
http://hlabs.spb.ru
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rand_chars.bundle
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070311/d093a73f/attachment.diff 


More information about the bazaar mailing list