[cairo-commit] perf/cairo-perf.c perf/cairo-perf.h

Carl Worth cworth at kemper.freedesktop.org
Thu Aug 31 11:19:52 PDT 2006


 perf/cairo-perf.c |   23 ++++-------------------
 perf/cairo-perf.h |   28 +++++++++++++---------------
 2 files changed, 17 insertions(+), 34 deletions(-)

New commits:
diff-tree 7f6e901a236ed267d396310fc56fa6bde697bfa2 (from b9f629d54239c43eef4746293bcffd58ada442f2)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Aug 31 11:19:48 2006 -0700

    perf: More simplification of PERF_LOOP macros.
    
    Here we drop both the start_timing and stop_timing functions,
    foliding their contents into main, PERF_LOOP_INIT and
    PERF_LOOP_FINI.

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 780cc88..1f7e167 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -27,7 +27,7 @@
 
 #include "cairo-perf.h"
 
-int cairo_perf_duration = -1;
+int cairo_perf_duration = 5;
 
 int cairo_perf_alarm_expired = 0;
 
@@ -80,24 +80,6 @@ target_is_measurable (cairo_test_target_
     }
 }
 
-void
-start_timing (bench_timer_t *tr) {
-    if (cairo_perf_duration == -1) {
-        if (getenv("CAIRO_PERF_DURATION"))
-            cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
-        else
-            cairo_perf_duration = 5;
-    }
-    tr->count = 0;
-    timer_start (tr);
-    set_alarm (cairo_perf_duration);
-}
-
-void
-stop_timing (bench_timer_t *tr) {
-    timer_stop (tr);
-}
-
 int
 main (int argc, char *argv[])
 {
@@ -108,6 +90,9 @@ main (int argc, char *argv[])
     cairo_t *cr;
     unsigned int size;
 
+    if (getenv("CAIRO_PERF_DURATION"))
+	cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
+
     for (i = 0; targets[i].name; i++) {
 	target = &targets[i];
 	if (! target_is_measurable (target))
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 23c377a..bea7494 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -43,12 +43,6 @@ typedef struct {
 
 #include "timer-alarm.h"
 
-void
-start_timing (bench_timer_t *tr);
-
-void
-stop_timing (bench_timer_t *tr);
-
 extern int cairo_perf_duration;
 extern int cairo_perf_alarm_expired;
 
@@ -58,20 +52,24 @@ extern int cairo_perf_alarm_expired;
  * out how to do an async timer.  On a quiet system, this doesn't
  * seem to significantly affect the results.
  */
-# define PERF_LOOP_INIT(timervar)  do {              \
-    start_timing(&(timervar));                       \
-    while (! cairo_perf_alarm_expired) {             \
+# define PERF_LOOP_INIT(timervar)  do {		\
+    timervar.count = 0;				\
+    timer_start (&(timervar));			\
+    set_alarm (cairo_perf_duration);		\
+    while (! cairo_perf_alarm_expired) {	\
         SleepEx(0, TRUE)
 #else
-# define PERF_LOOP_INIT(timervar)  do {              \
-    start_timing(&(timervar));                       \
+# define PERF_LOOP_INIT(timervar)  do {		\
+    timervar.count = 0;				\
+    timer_start (&(timervar));			\
+    set_alarm (cairo_perf_duration);		\
     while (! cairo_perf_alarm_expired) {
 #endif
 
-#define PERF_LOOP_FINI(timervar)                \
-    (timervar).count++;                         \
-    }                                           \
-    stop_timing (&(timervar));                  \
+#define PERF_LOOP_FINI(timervar)		\
+    (timervar).count++;				\
+    }						\
+    timer_stop (&(timervar));			\
     } while (0)
 
 #define PERF_LOOP_RATE(timervar)		\


More information about the cairo-commit mailing list