ZJ.Mike.2009 has asked for the
wisdom of the Perl Monks concerning the following question:

I wrote two very simple scripts, one in wxPerl, the other in Win32::GUI as will be shown below. They basically do the same thing, i.e. open a fairly large text file (30MB), takes the query input from the textbox, search the text file using the query and display relevant results if any in another textbox. I've noticed the wxPerl version is generally much slower (about 7 seconds or more) than the Win32-GUI version.

I'm wondering if this is just normal (I'm not sure if the problem is reproducible but I think so) or if something can be done to improve the speed of the wxPerl version.

Thanks to GrandFather and @Anonmous Monk, I'm beginning to suspect that it might also have something to do with character encoding. I just wrote a Tk version and it runs *about as fast* as the Win32::GUI version but the Chinese characters contained in the file are garbled. I'll keep the post updated.
Thanks.

UPDATE2

Just wrote a simple Tk version. It runs about as fast as the Win32::GUI. I'm thinking maybe the problem I'm experiencing is somehow related to character encoding. The following is a Tk version.

Just found the Tk version runs about as fast as the Win32::GUI when all Chinese characters in the data file become garbled. And if I resave the data file as utf8 or use the following file open argument:

, all the Chinese characters contained in the data file will display properly but at the same time the speed suffers significanly and the Tk version will run just as slow as the wxPerl version.

Conclusion (?)

Win32::GUI is faster than wxPerl in my case perhaps because the data file used in my case contains both English and Chinese characters and the Chinese characters get displayed much faster on screen when using the native API of a Chinese system.

Another Test

This time I deleted all Chinese characteres contained in the 30MB data file, and then I tried wxPerl, Win32::GUI and Tk versions again. The result is this:

Tk is about as fast as Win32::GUI

wxPerl is still slower than Win32::GUI. In my previous test, it was about 7-8 seconds slower, but now the gap narrows to 3-4 seconds.

Win32::GUI is Windows specific and is a thin layer over the native Windows GUI code. wxPerl on the other hand is a cross-platform wrapper around whatever system it happens to be running on. That portability comes at a price due to multiple abstraction layers which cost in terms of performance.

If you don't need portability and are happy with the API of Win32::GUI go for it. I have no experience of wxPerl, but Tk (another cross-platform GUI) provides a simpler API than Win32::GUI as well as being cross-platform, so may be attractive for that reason where performance is less critical (the same is likely true of wxPerl).

Win32::GUI is faster than wxPerl in my case perhaps because the data file used in my case contains both English and Chinese characters and the Chinese characters get displayed much faster on screen when using the native API of a Chinese system.

Is your wxPerl built with unicode support?

In my latest results, wxPerl is the fastest by a one to two seconds

$ perl zj907592tk.pl
Total running time: 00:00:07
at zj907592tk.pl line 64, <$data> line 7553.
$ perl zj907592w32.pl
Total running time: 00:00:08
at zj907592w32.pl line 64, <$data> line 7553.
$ perl zj907592wx.pl
Total running time: 00:00:06
at zj907592wx.pl line 70, <$data> line 7553.
Total running time: 00:00:06
at zj907592wx.pl line 70, <$data> line 7553.

@Anonymous Monk, thanks for the testing. The result is very interesting but I'm wondering if wxPerl would be still the fastest when you also get the Chinese characters displayed properly.

And yes, my wxPerl fully supports unicode. Is there a wxPerl version that does not support Unicode? The thing is this: Win32::GUI does not support Unicode (even though my system fully supports Chinese and Unicode, Chinese characters encoded in utf8 get garbled in my Win32::GUI app). Tk partially supports Unicode. It does not support Unicode characters outside the basic multilingual plane (if my Tk app contains unicode characters outside the BMP, Tk crashes with a codepoint too high warning). Fortunately, wxPerl is the one that fully supports Unicode.

The result is very interesting but I'm wondering if wxPerl would be still the fastest when you also get the Chinese characters displayed properly.

The speed difference is well within the margin for noise. The only reason I mentioned it, is because it has been consistent in my tests. I doubt having a chinese font would make a difference (not going to test).

And yes, my wxPerl fully supports unicode. Is there a wxPerl version that does not support Unicode?

I use Tcl::Tk on a regular basis and really happy with this.After some 10+ years of usage of this approach - I understood that this is the perfect balance of simplicity and power for my GUIs.
Nicer GUI libs often require more efforts during coding, so I haven't switched to these.

often I use pure Tcl CPAN module instead of Tcl::Tk, because I rarely actually need that perl/Tk syntax,