[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Faster SDL_Image
Guys,
After my PC crashed I was forced to rebuild the pygame from sources
including SDL_Image.
While doing it I noticed significant difference between my SDL_Image loading
performance and stock SDL one.
Stock:
Load 100 images "data\babytux.png" took 3.25 secs ( 30.77 img/sec )
Load 100 images "data\bkgrnd2.png" took 8.08 secs ( 12.38 img/sec )
Load 100 images "data\bg.jpg" took 1.17 secs ( 85.40 img/sec )
Load 100 images "data\cupsplash-menuad-overlay.png" took 5.72 secs ( 17.49
img/sec )
Load 100 images "data\the-cat.png" took 3.98 secs ( 25.10 img/sec )
Mine:
Load 100 images "data\babytux.png" took 2.19 secs ( 45.72 img/sec )
Load 100 images "data\bkgrnd2.png" took 5.11 secs ( 19.57 img/sec )
Load 100 images "data\bg.jpg" took 0.81 secs ( 123.00 img/sec )
Load 100 images "data\cupsplash-menuad-overlay.png" took 4.25 secs ( 23.53
img/sec )
Load 100 images "data\the-cat.png" took 2.95 secs ( 33.86 img/sec )
If you want to take advantage of it just take this:
http://pymedia.org/downloads/SDL_image.dll
and replace the one which comes in 1.6+ release. Speedup guaranteed !
Script attached.
Dmitry/
import pygame
import time, sys
LOAD_COUNT= 100
IMG_NAME= 'data/bg.jpg'
def loadImages( img ):
start= time.time()
cnt= LOAD_COUNT
for i in xrange( cnt ):
s= pygame.image.load( img )
delta= time.time()- start
print 'Load %d images "%s" took %.2f secs ( %.2f img/sec )' % ( cnt, img, delta, cnt/delta )
pygame.init()
s= IMG_NAME
if len( sys.argv )== 2:
s= sys.argv[ 1 ]
loadImages( s )
pygame.quit()