mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-04 22:20:28 +01:00
[perf] Enable traces to be interrupted
Waiting for a long running benchmark can be very annoying, especially if you just want a rough-and-ready result. So hook into SIGINT and stop the current benchmark (after the end of the iteration) on the first ^C. A second ^C within the same iteration will kill the program as before.
This commit is contained in:
parent
2eaced2447
commit
5c2e73e74c
1 changed files with 19 additions and 1 deletions
|
|
@ -44,6 +44,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if HAVE_FCFINI
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#endif
|
||||
|
|
@ -147,6 +149,19 @@ _similar_surface_create (void *closure,
|
|||
return cairo_surface_create_similar (closure, content, width, height);
|
||||
}
|
||||
|
||||
static int user_interrupt;
|
||||
|
||||
static void
|
||||
interrupt (int sig)
|
||||
{
|
||||
if (user_interrupt) {
|
||||
signal (sig, SIG_DFL);
|
||||
raise (sig);
|
||||
}
|
||||
|
||||
user_interrupt = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
execute (cairo_perf_t *perf,
|
||||
cairo_surface_t *target,
|
||||
|
|
@ -202,7 +217,7 @@ execute (cairo_perf_t *perf,
|
|||
}
|
||||
|
||||
low_std_dev_count = 0;
|
||||
for (i = 0; i < perf->iterations; i++) {
|
||||
for (i = 0; i < perf->iterations && ! user_interrupt; i++) {
|
||||
cairo_script_interpreter_t *csi;
|
||||
|
||||
csi = cairo_script_interpreter_create ();
|
||||
|
|
@ -242,6 +257,7 @@ execute (cairo_perf_t *perf,
|
|||
}
|
||||
}
|
||||
}
|
||||
user_interrupt = 0;
|
||||
|
||||
if (perf->summary) {
|
||||
_cairo_stats_compute (&stats, times, i);
|
||||
|
|
@ -473,6 +489,8 @@ main (int argc, char *argv[])
|
|||
stderr);
|
||||
}
|
||||
|
||||
signal (SIGINT, interrupt);
|
||||
|
||||
if (getenv ("CAIRO_TRACE_DIR") != NULL)
|
||||
trace_dir = getenv ("CAIRO_TRACE_DIR");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue