rendering statistics are now optional (-v).
This commit is contained in:
parent
b519b83bd3
commit
9f7ce3e774
20
balls.c
20
balls.c
@ -317,17 +317,23 @@ void print_usage (const char * progname) {
|
|||||||
"\tradius=<min-radius>-<max-radius>\n"
|
"\tradius=<min-radius>-<max-radius>\n"
|
||||||
"\tv=<min-velocity>-<max-velocity>\n"
|
"\tv=<min-velocity>-<max-velocity>\n"
|
||||||
"\tdelta=<frame-delta-time>\n"
|
"\tdelta=<frame-delta-time>\n"
|
||||||
"\tclear=<clear-alpha>\n",
|
"\tclear=<clear-alpha>\n"
|
||||||
|
"\t-v :: enables rendering timing statitstics\n",
|
||||||
progname);
|
progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rendering_statistics = 0;
|
||||||
|
|
||||||
gboolean timeout (gpointer user_data) {
|
gboolean timeout (gpointer user_data) {
|
||||||
guint64 start = g_get_monotonic_time ();
|
guint64 start = 0, elapsed_usec;
|
||||||
|
if (rendering_statistics)
|
||||||
|
start = g_get_monotonic_time ();
|
||||||
|
|
||||||
update_state();
|
update_state();
|
||||||
draw_balls_onto_window();
|
draw_balls_onto_window();
|
||||||
|
|
||||||
guint64 elapsed_usec = g_get_monotonic_time () - start;
|
if (rendering_statistics) {
|
||||||
|
elapsed_usec = g_get_monotonic_time () - start;
|
||||||
|
|
||||||
static guint64 elapsed_usec_total = 0;
|
static guint64 elapsed_usec_total = 0;
|
||||||
static unsigned int samples = 0;
|
static unsigned int samples = 0;
|
||||||
@ -339,6 +345,7 @@ gboolean timeout (gpointer user_data) {
|
|||||||
}
|
}
|
||||||
++samples;
|
++samples;
|
||||||
elapsed_usec_total += elapsed_usec;
|
elapsed_usec_total += elapsed_usec;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,6 +374,10 @@ int main (int argc, const char *argv[]) {
|
|||||||
}
|
}
|
||||||
if (sscanf(argv[i], "clear=%lf", &clear_alpha) == 1)
|
if (sscanf(argv[i], "clear=%lf", &clear_alpha) == 1)
|
||||||
continue;
|
continue;
|
||||||
|
if (strcmp(argv[i], "-v") == 0) {
|
||||||
|
rendering_statistics = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -398,6 +409,9 @@ int main (int argc, const char *argv[]) {
|
|||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
|
if (rendering_statistics)
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
destroy_graphics();
|
destroy_graphics();
|
||||||
free(balls);
|
free(balls);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user