GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Jul 22, 2014 11:38 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: pixbufloader close performance
PostPosted: Sun Jul 15, 2012 8:31 am 
Offline

Joined: Sun Jul 15, 2012 8:18 am
Posts: 3
I'm trying to do background loading of images out of the idle callback.
I was using pixbuf new_from_file, but that creates a two second blockage (I'm loading 3.5mb 3648x2736 jpegs).
So I switched to using a bixbufloader, what I discovered then is that reading the file off the drive and shoving it into the loader takes 10's of milliseconds. And calling close on the loader creates another 2 second blockage.
This is with pygtk 2.28.3 on windows 7 64bit with python2.7 and gtk 2.24.10.

Comments are typical run times in milliseconds.
Code:
import time
import gtk

last_time = time.time()
def mark(val):
    global last_time
    print val, time.time() - last_time
    last_time = time.time()

pbl = gtk.gdk.PixbufLoader()  # 0ms
mark(1)
data = open("slow.jpg", "rb").read()  # 53ms
mark(2)
pbl.write(data) # 2ms
mark(3)
pbl.close() # 2132ms
mark(4)
pb = pbl.get_pixbuf() # 1ms
mark(5)


Is this expected behavior?
Am I doing something wrong?
Is there some library that needs to be installed for faster image processing?
Is trying to load images out of the idle callback just wrong headed to start with?

G


Last edited by tolomea on Tue Jul 17, 2012 5:32 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: pixbufloader close performance
PostPosted: Tue Jul 17, 2012 3:25 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the GTK+ forums!

Hmm, not sure what could cause this delay. On my modest machine (cca. 4 years old 2GHz Core2Duo, 2GB ram) running GNU/Linux (Gentoo, x86-64) I get this:
Code:
1 0.000136852264404
2 0.00334405899048
3 0.259651899338
4 5.79357147217e-05
5 2.69412994385e-05


So, as expected, most of the time is spent decoding image (cca. 250 ms). Loading takes a few milliseconds and all other operations are basically instantaneous. Maybe it's the Windows part that makes the difference? And BTW, GTK+ is stuck at 2.24.x version, so your version information is a bit strange. 2.18.3 maybe?

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: pixbufloader close performance
PostPosted: Tue Jul 17, 2012 5:34 pm 
Offline

Joined: Sun Jul 15, 2012 8:18 am
Posts: 3
You are right about the version info, I had confused the gtk and pygtk versions, I have corrected it now.


Top
 Profile  
 
 Post subject: Re: pixbufloader close performance
PostPosted: Tue Jul 17, 2012 9:03 pm 
Offline

Joined: Sun Jul 15, 2012 8:18 am
Posts: 3
Perhaps it's the files I am dealing with, I have uploaded slow.jpg here:
http://www.tolomea.com/slow.jpg


Top
 Profile  
 
 Post subject: Re: pixbufloader close performance
PostPosted: Tue Jul 17, 2012 9:30 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 733
Location: UK
On my fairly up to date machine (Intel i5-2500k 3.3GHz 8Gb RAM) I got these results
Code:
1 3.09944152832e-05
2 0.00126385688782
3 0.155215024948
4 2.28881835938e-05
5 1.21593475342e-05
So it does look like most of the time processing is done in decoding the image. But it is to be expected with an image that size. Even loading the image in an image viewer takes some time.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group