Twin Performance

Well, I had an adventure today. I wanted to find out whether twin was going to run acceptably fast on my target platform, so I decided to get some profiling data. Unfortunately, gprof doesn't (natively) work on multi-threaded applications. Fortunately, google found 'gprof-helper.c' which did manage to get reasonable profiling data.

As usual, profiling uncovered many bugs in my program, as well as a probably bug in some cairo code.

I saw trig functions being called hundreds of thousands of times when painting a simple clock face and went to investigate. Turns out the function Carl and I wrote to compute the number of vertices needed to approximate a circle within a specified error tolerance was almost completely bogus. After figuring out a suitable replacement, the clock was actually keeping up with time. There are still the expected performance issues of software compositing, but given that the target CPU is not an x86, I'll have to wait until I've got hardware and a compiler to try and speed those up.

I'd also like to fix the text so that curves weren't roughly approximated with line segments. For small text, it's not bad, but for larger characters, it looks pretty awful. I'll have to go find some spline fitting code and see what I can manage.