mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 10:18:02 +02:00
perf: Switch from alarm to setitimer for more fine-grained control of timers
This commit is contained in:
parent
2ebb9af434
commit
6ae6d91c0c
5 changed files with 20 additions and 7 deletions
|
|
@ -63,8 +63,21 @@ alarm_handler (int signal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_alarm (int seconds) {
|
set_alarm (double seconds) {
|
||||||
|
struct itimerval tr;
|
||||||
|
long sec, usec;
|
||||||
|
|
||||||
cairo_perf_alarm_expired = 0;
|
cairo_perf_alarm_expired = 0;
|
||||||
signal (SIGALRM, alarm_handler);
|
signal (SIGALRM, alarm_handler);
|
||||||
alarm (seconds);
|
|
||||||
|
sec = floor (seconds);
|
||||||
|
seconds -= sec;
|
||||||
|
usec = seconds * 1e6;
|
||||||
|
|
||||||
|
tr.it_interval.tv_sec = 0;
|
||||||
|
tr.it_interval.tv_usec = 0;
|
||||||
|
tr.it_value.tv_sec = sec;
|
||||||
|
tr.it_value.tv_usec = usec;
|
||||||
|
|
||||||
|
setitimer (ITIMER_REAL, &tr, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ alarm_handler (void *closure, DWORD dwTimerLowValue, DWORD dwTimerHighValue) {
|
||||||
|
|
||||||
HANDLE hTimer = NULL;
|
HANDLE hTimer = NULL;
|
||||||
void
|
void
|
||||||
set_alarm (int seconds) {
|
set_alarm (double seconds) {
|
||||||
if (hTimer == NULL)
|
if (hTimer == NULL)
|
||||||
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
|
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
cairo_perf_alarm_expired = 0;
|
cairo_perf_alarm_expired = 0;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,6 @@ void
|
||||||
alarm_handler (int signal);
|
alarm_handler (int signal);
|
||||||
|
|
||||||
void
|
void
|
||||||
set_alarm (int seconds);
|
set_alarm (double seconds);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "cairo-perf.h"
|
#include "cairo-perf.h"
|
||||||
|
|
||||||
int cairo_perf_duration = 1;
|
double cairo_perf_duration = 1;
|
||||||
|
|
||||||
int cairo_perf_iterations = 10;
|
int cairo_perf_iterations = 10;
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ main (int argc, char *argv[])
|
||||||
stats_t stats;
|
stats_t stats;
|
||||||
|
|
||||||
if (getenv("CAIRO_PERF_DURATION"))
|
if (getenv("CAIRO_PERF_DURATION"))
|
||||||
cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
|
cairo_perf_duration = strtod(getenv("CAIRO_PERF_DURATION"), NULL);
|
||||||
|
|
||||||
if (getenv("CAIRO_PERF_ITERATIONS"))
|
if (getenv("CAIRO_PERF_ITERATIONS"))
|
||||||
cairo_perf_iterations = strtol(getenv("CAIRO_PERF_ITERATIONS"), NULL, 0);
|
cairo_perf_iterations = strtol(getenv("CAIRO_PERF_ITERATIONS"), NULL, 0);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include "cairo-perf-timer.h"
|
#include "cairo-perf-timer.h"
|
||||||
|
|
||||||
extern int cairo_perf_duration;
|
extern double cairo_perf_duration;
|
||||||
extern int cairo_perf_alarm_expired;
|
extern int cairo_perf_alarm_expired;
|
||||||
|
|
||||||
#if CAIRO_HAS_WIN32_SURFACE
|
#if CAIRO_HAS_WIN32_SURFACE
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue