Statistics / Graphs widget

Hello,

is there a simple way to draw graphics in a ruby-gtk app ? I mean
something
like the CPU load graph in gnome-system-monitor.

I’ll also need to draw statistics later. I’m interested in a any
suggestion :slight_smile:

Regards,
Christophe H.

Christophe,

Here’s something to keep in mind:

All applications using the Ruby-Gnome2 bindings suffer from garbage
collection pauses of upwards of 1/5th of a second (on a P3-1.2ghz…
much worse on handhelds, etc.).

This is due to implementation issues in the bindings and may be fixed
some day, but for now, if you plan to animate the graph at anything
above about 2 frames per second, I recommend you use a different
language/binding combination (as far as I know Python/GTK+ doesn’t have
the same problem).

More info:

-Ian

Am Freitag, den 23.11.2007, 15:18 -0300 schrieb Ian McIntosh:

Christophe,

Here’s something to keep in mind:

All applications using the Ruby-Gnome2 bindings suffer from garbage
collection pauses of upwards of 1/5th of a second (on a P3-1.2ghz…
much worse on handhelds, etc.).

Hi,

this is not compleatly true. With Klötzle i made a stop motion animation
programm, which has a live preview from a video camera. This works smoth
with up to 15 frames / second on a 1.25 Ghz Mac Mini.

You only have to trigger the garbage collector yourself. In my case it
is enought once per second.

Cheers
detlef

  • dcad
    392 objects, 0.001476 GC time, 391 remain
    • 393 objects, 0.001331 GC time, 391 remain
      393 objects, 0.001326 GC time, 391 remain
    • 393 objects, 0.002924 GC time, 391 remain
    • …gtk loaded…
    • 11648 objects, 0.014791 GC time, 5172 remain
    • 5174 objects, 0.052599 GC time, 5171 remain
    • 5173 objects, 0.018333 GC time, 5171 remain
    • 5173 objects, 0.056349 GC time, 5169 remain
    • 5171 objects, 0.056296 GC time, 5169 remain

dcad

(Oops sorry about that last post, Evolution flipped out on me after
pasting formatted text, I shouldn’t be allowed to use a computer…)

detlef,

In your 15 fps app, you need a new frame every 0.066 (1/15) seconds,
right?

On my PC, in my testing, simply including the ruby-gnome bindings causes
garbage collection time to jump from around 0.002 to 0.056 (see results
below).

So it would seem possible to do 15fps, assuming it took minimal time to
generate a frame.

However, it seems that the garbage collection process takes longer the
more GObjects you have. So if you expand your GUI, you’ll notice longer
pauses in your animation. It’s really a crazy situation… :smiley:

I haven’t tested the GC time of a Ruby/Gtk+ app on a Maemo, OLPC, etc.,
but since they have much slower CPUs I assume that the situation is
worse there.

-Ian

403 objects, 0.047237 GC time, 390 remain
392 objects, 0.001476 GC time, 391 remain
393 objects, 0.001331 GC time, 391 remain
393 objects, 0.001326 GC time, 391 remain
393 objects, 0.002924 GC time, 391 remain
…gtk loaded…
11648 objects, 0.014791 GC time, 5172 remain
5174 objects, 0.052599 GC time, 5171 remain
5173 objects, 0.018333 GC time, 5171 remain
5173 objects, 0.056349 GC time, 5169 remain
5171 objects, 0.056296 GC time, 5169 remain

Ok, it’s not a problem for me, as the animation will be around 1
frame each 5 seconds.

Have you got an idea about which widget I should use ?

Regards,

Christophe H.

this widget interests me also.
i’d start with an empty widget, and use it’s Gdk::Drawable, but i hope
people here have a better idea.

On Nov 24, 2007 1:02 AM, Christophe H. [email protected] wrote:

Ok, it’s not a problem for me, as the animation will be around 1
frame each 5 seconds.

Have you got an idea about which widget I should use ?

Normally, GtkDrawingArea is used in such a case.

http://library.gnome.org/devel/gtk/unstable/GtkDrawingArea.html

It should work properly if you will use “higher-level” GDK drawing
primitives (drawing rectangles, polygons, pictures), but it will
probably be too slow if you draw pixels, in which case you’ll need to
use a C extension alongside your ruby program.


Guillaume C. - Guillaume Cottenceau

Grism looks very nice, hopefully others can present with such good
styled apps too.

In Grism (www.grism.org), I draw stock charts using a GtkDrawingArea and
a
Cairo context. The charts are not animated, but if you resize the chart
window, the chart automatically resizes (actually, it preforms a
redraw).
Based my experience with the performance of this operation, you will not
have any problems with performance.

Cheers,
Nick