Re: high-level text drawing


Hi Olexiy:
      Attatch is the program I make for the test. 
      You may try it and will find what's wrong with this test
      I run this program on a sun box and the Xserver is Exceed7.1.1.

Attached is a patch to your test that puts pango layout and font description out of the loop and that uses 
times(2) for CPU time comparison instead of the wallclock ftime function.

The slowness may be explained by the following points:
- pango xft uses antialiasing => drawing a string need the knowledge of the 
underlying pixel => overhead. 
- you use an exported X window (non local Xserver) => the data exchange due 
to the previous point is slow due to the network link (on a local machine, I did 
not see any difference in my tests due to antialiasing). Exceed may not support XRENDER extension.
- font lookup is done differently.
- you create and destroy a pango layout and a font description in the loop: if 
font description does not change, it is fairer comparison to put these out of the 
- pango text is UTF8 with potential right-to-left and left-to-right text, so text 
analysis and glyph lookup is inherently more complex than in xdrawstring.
- you use ftime(), ie wallclock time to compare performance: this is not 
accurate as it also depends on the load of your system. Use times(2) to count 
CPU clocks (to convert them to seconds, use sysconf(CLOCK_PER_SEC). This 
will advantage the Xdrawstring, as font lookup and glyphs rasterisation are 
done on server side)
- font rasterisation: you must be sure that both drawing methods use the same 
font: for a fairer comparison, use a non-bitmap font. With XDrawString, the 
rasterisation is done by the server, with pango, it is done by the client, so CPU 
time of rasterisation cannot be elapsed using times(2) (we may use wall clock 
time if we can ascertain that the machine load is constant during the test).
- it is better need to run longer tests (XDrawString should run at least for few 
seconds) , especially on fast machines.

My testings show that in this test pango is ~80 times (3e-2 s/string vs 3.8e-4 s/
string) slower than XDrawString. This is on a PII266Mhz, ATI Radeon All-In-
Wonder 32Mb, with gtk suite from cvs. Considering the benefits of Pango, this 
is acceptable (of course, a speed up by a factor of two would surely end all
complaints about slowness).

Melvin Hadasht

Attachment: drawtxt.diff
Description: Text Data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]