FLTK runs an order of magnitude slower if I change my locale from
ISO8859-1 to UTF-8. This is most annoying in the Fl_Menu_Bar widget.
Here is a description of the problem:
Test program:
--------------------------------------------------------------------------------
#include <cstdlib>
#include <FL/Fl.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Window.H>
int main(void)
{
Fl_Window* w = new Fl_Window(700, 400, "Test");
w->begin();
Fl_Menu_Bar* m = new Fl_Menu_Bar(0, 0, 700, 30);
m->add("Menu1/Entry1", "^x", NULL, NULL);
m->add("Menu2/Entry2", "^y", NULL, NULL);
m->add("Menu3/Entry3", "^z", NULL, NULL);
w->end();
w->show();
Fl::wait();
exit(0);
}
--------------------------------------------------------------------------------
$ uname -s -r
NetBSD 5.1
$ cat /proc/cpuinfo | grep name
model name : Intel(R) Pentium(R) 4 CPU 1500MHz
$ Xorg -version
X.Org X Server 1.6.5
[...]
$ fltk-config --version
1.3.0
$ fltk-config -g --compile x.cxx
$ export LC_CTYPE=en_US.ISO8859-1
$ time -p ./x
real 0.12
user 0.05
sys 0.02
$ export LC_CTYPE=en_US.UTF-8
$ time -p ./x
real 0.86
user 0.66
sys 0.02
With the UTF-8 locale it consumes approx. half a second more CPU time.
Tracing the program with ktruss and gdb showed, that the lengthy
operation seems to be parsing one of the following files triggered via
_XimParseStringFile() by XOpenIM():
/usr/pkg/share/X11/locale/iso8859-1/Compose
/usr/pkg/share/X11/locale/en_US.UTF-8/Compose
The two files are 20KByte vs 500KByte in size on my system, this
explains the difference in time required to parse them. Up to this
point: Who cares if this happens once at startup.
But it happen very often while the program is running. Replace
Fl::wait() with Fl::run() in the program above so that it stay open and:
- Rebuild and start the program
- Open one of the three pull-down menus by clicking it
- Move the mouse to the other menu entries
Every time when you hit a new menubar entry, both (the old and the new
one) will disappear and a delay twice as long as the startup delay occur
before the new menu and both entries of the menubar reapprear.
Note: Moving the mouse over the entries inside a pulldown menu is not
slow.
With the ISO locale it feels only a bit slow, but with the Unicode
locale the delay is over 1s and it is completely unusable. Tracing
showed that for every delay the locale files are parsed again and again!
What is wrong here? It can't really be intended behaviour to trigger
processing megabytes of data only by moving the mouse over the menu bar.
BTW: Popup windows created by fl_message() are delayed in the same way.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk