Line Benchmarks Tkinter vs. wxPython

Gordon Williams g_will at cyberus.ca
Mon Nov 15 15:22:16 EST 1999


Hello All,

I have done some benchmark testing to see the difference in speed between
plotting multi point lines using Tkinter and wxPython.  I have looked at 3
different methods for doing it in Tk and 2 different methods in wx.  The
differences are astounding for the 1000 to 10000 point lines that I
examined.  Generally, wx was found to be in the order of 200 to 1800 times
faster than the standard Tkinter.  Tk can be sped up by ten to 50 times by
changing Tkinter so it bypasses the _flatten method or by making the Tk
calls directly.

A repeating sine wave was created and put into a horizontal scrollable
window of about 500 points wide and 300 points high.  These are the results
for the line plotting time only.

Time in Seconds on a P166 with 96MB RAM.

Points		Tkinter		Tkinter		Tkinter		wxPython	wxPython
(standard)	(mod 1)	(mod 2)	(direct draw)	(bitmap)
1000		1.190		0.192		.202		0.007		0.026
2000		4.406		0.385		--		0.014		0.042
5000		25.170		0.967		--		0.027		0.080
10000		100.260	1.941		2.064		0.054		0.148

Notes:
1)	Tk standard is the standard usage with no modifications.

2)	Tk mod 1 has Tkinter modified so a flat tuple of points is passed to
create_line and _flatten is by-passed.

3)	Tk mod 2 used the apply method  e.g. 
apply(self.can.tk.call,(self.can._w,'create','line') + points + 
('-width',1,'-fill',colour,'-tags',"tag"))

4)	wx direct draw draws to the window directly.

5)	wx bitmap draws to a bitmap and then blit



Conclusions:

1)	The time to plot lines using the standard Tkinter is quadratic with the
number of points (ugh!).  This is due to the time spent in _flatten. 
_flatten is very versatile but agonizingly slow for large numbers of lines.

2)	Tkinter mod 1 and 2 give the same results.  Times are linear with the
number of points plotted as both cases dont use the _flatten method.  This
means that a flat tuple of points has to be used (a small constraint).  The
speed increase in doing this is from 10 to 50 times over the standard.

3)	wxPython beats Tk by a very! large margin even when Tk is called
directly.  Direct drawing onto to screen is roughly 3 times faster than
using a bitmap.



Thanks to:
Greg Landrum for providing some information on direct calls to tk.
Ionel Simionescu for providing the wxPython code which I was able to
modify.





More information about the Python-list mailing list