[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] converting byte image for display




On Jan 1, 2006, at 9:00 PM, Simon Wittber wrote:
Benchmarks are fun.

Sure are. :)


In your test_concat function, you are testing a function call as well
as the concat process. This will add extra time to that benchmark,
which the other benchmarks don't have.

I noticed this but left the function call in on purpose because that is what the original poster was going to be doing anyways.


Also, you are using a very small 3 item list for the test. a 320x200
256 color image will have 64000 bytes.

Using

test_list = "a" * 64000
test_count = 100

these were my results:

concat: 6.103
  map1: 6.349
  map2: 6.303

String concantenation used to be quite slow in Python 2.3, but has
since recieved some optimisation.

http://mail.python.org/pipermail/python-list/2004-September/ 242125.html

http://mail.python.org doesn't want to load for me but http://python.org will, weird.

Anyways, it appears that string concatenation is now faster than using
the built-in function join and map.


Also, you may want to try using a list comprehension, which will be quite fast.

def test_list_comp(test_count, test_list):
   t = pygame.time.get_ticks()
   for i in range(test_count):
      a = ''.join([i*3 for i in test_list])
   return pygame.time.get_ticks() - t


This score 2.743 on my box.

Yep, list comprehension was significantly faster on my box too. Thanks for the suggestion.


-Sw.
__
Trevor Fancher
http://fancher.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature