curious time overhead for vscales
- From: est hyperreal org
- To: gtk-list redhat com
- Subject: curious time overhead for vscales
- Date: Thu, 17 Feb 2000 18:01:14 -0800 (PST)
Check this out if you might have insights (or concerns) about the
overhead of multiple updates to multiple vscales. :)
Eric
---- levels.c ----
/*
This benchmark subjects 10 vscales to around a thousand
modifications a second. When given an argument (e.g., "./levels
foo") it adjusts all 10 vscales to new values a hundred times a
second. When not given an argument ("./levels") it adjusts one of
the vscales a hundred times every tenth of a second. My
understanding of GTK will be much improved when I understand why the
first case seems to use dramatically less cpu than the second (as
revealed by time and top). It almost seems it should be the other
way around. :)
*/
#include <gtk/gtk.h>
#define N 10
GtkObject *as[N];
int val = 0, idx = 0;
int
foo(void *v)
{
int i;
for (i = 0; i < N; i++)
{
gtk_adjustment_set_value(GTK_ADJUSTMENT(as[i]), val/100.0);
val = (val + 1) % 101;
}
return 1;
}
int
bar(void *v)
{
int i;
for (i = 0; i < 101; i++)
{
gtk_adjustment_set_value(GTK_ADJUSTMENT(as[idx]), i/100.0);
idx = (idx + 1) % N;
}
return 1;
}
void
delcb(GtkWidget *w, gpointer data)
{
gtk_main_quit();
}
int
main(int argc, char **argv)
{
GtkWidget *w, *h, *s;
int i;
gtk_init(&argc, &argv);
w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(w), "delete_event",
GTK_SIGNAL_FUNC(delcb), GTK_OBJECT(w));
h = gtk_hbox_new(0, 0);
gtk_container_add(GTK_CONTAINER(w), h);
for (i = 0; i < N; i++)
{
as[i] = gtk_adjustment_new(.5, 0, 1, .01, .1, 0);
s = gtk_vscale_new(GTK_ADJUSTMENT(as[i]));
gtk_scale_set_digits(GTK_SCALE(s), 2);
gtk_box_pack_start(GTK_BOX(h), s, 0, 0, 0);
}
gtk_widget_show_all(w);
if (argc > 1)
gtk_timeout_add(10, foo, 0);
else
gtk_timeout_add(100, bar, 0);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]