perf: Make cairo_perf_timer structure private. Make timer functions void.

This commit is contained in:
Benjamin Otte 2006-09-05 22:48:38 -07:00 committed by Carl Worth
parent 1bb6f9fb10
commit df8cc10073
4 changed files with 36 additions and 30 deletions

View file

@ -36,22 +36,30 @@
/* timers */
static cairo_perf_timer_t tr;
struct _cairo_perf_timer_t
{
struct timeval start;
struct timeval stop;
};
void
timer_start (cairo_perf_timer_t *tr) {
gettimeofday (&tr->start, NULL);
timer_start (void) {
gettimeofday (&tr.start, NULL);
}
void
timer_stop (cairo_perf_timer_t *tr) {
gettimeofday (&tr->stop, NULL);
timer_stop (void) {
gettimeofday (&tr.stop, NULL);
}
double
timer_elapsed (cairo_perf_timer_t *tr) {
timer_elapsed (void) {
double d;
d = tr->stop.tv_sec - tr->start.tv_sec;
d += (tr->stop.tv_usec - tr->start.tv_usec) / 1000000.0;
d = tr.stop.tv_sec - tr.start.tv_sec;
d += (tr.stop.tv_usec - tr.start.tv_usec) / 1000000.0;
return d;
}

View file

@ -34,24 +34,32 @@
/* timers */
struct _cairo_perf_timer_t
{
LARGE_INTEGER start;
LARGE_INTEGER stop;
};
static cairo_perf_timer_t tr;
void
timer_start (cairo_perf_timer_t *tr) {
QueryPerformanceCounter(&tr->start);
timer_start (void) {
QueryPerformanceCounter(&tr.start);
}
void
timer_stop (cairo_perf_timer_t *tr) {
QueryPerformanceCounter(&tr->stop);
timer_stop (void) {
QueryPerformanceCounter(&tr.stop);
}
double
timer_elapsed (cairo_perf_timer_t *tr) {
timer_elapsed (void) {
double d;
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
d = (tr->stop.QuadPart - tr->start.QuadPart) / (double) freq.QuadPart;
d = (tr.stop.QuadPart - tr.start.QuadPart) / (double) freq.QuadPart;
return d;
}

View file

@ -30,29 +30,20 @@
#include "cairo-perf.h"
typedef struct _cairo_perf_timer_t {
#ifdef USE_WINAPI
LARGE_INTEGER start;
LARGE_INTEGER stop;
#else
struct timeval start;
struct timeval stop;
#endif
long count;
} cairo_perf_timer_t;
typedef struct _cairo_perf_timer_t cairo_perf_timer_t;
/* timers */
extern int alarm_expired;
void
timer_start (cairo_perf_timer_t *tr);
timer_start (void);
void
timer_stop (cairo_perf_timer_t *tr);
timer_stop (void);
double
timer_elapsed (cairo_perf_timer_t *tr);
timer_elapsed (void);
/* alarms */

View file

@ -29,16 +29,15 @@ static double
do_paint (cairo_t *cr)
{
int i;
cairo_perf_timer_t timer;
timer_start (&timer);
timer_start ();
for (i=0; i < 3; i++)
cairo_paint (cr);
timer_stop (&timer);
timer_stop ();
return 1.0 / timer_elapsed (&timer);
return 1.0 / timer_elapsed ();
}
double