[cairo-commit] perf/util.c
Carl Worth
cworth at kemper.freedesktop.org
Thu Aug 31 10:33:42 PDT 2006
perf/util.c | 177 ------------------------------------------------------------
1 files changed, 177 deletions(-)
New commits:
diff-tree a60ed68daebc15e87ededbca80211508f624bcb6 (from 739c4767673ace4f566d395d770924617ddebaff)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Aug 31 10:33:24 2006 -0700
perf: Remove unused util.c
diff --git a/perf/util.c b/perf/util.c
deleted file mode 100644
index af1a2ef..0000000
--- a/perf/util.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright © 2006 Mozilla Corporation
- * Copyright © 2006 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * the authors not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. The authors make no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: Vladimir Vukicevic <vladimir at pobox.com>
- * Carl Worth <cworth at cworth.org>
- */
-
-#define _GNU_SOURCE
-
-#ifdef USE_WINAPI
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <string.h>
-
-#ifndef USE_WINAPI
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-#include "cairo-bench.h"
-
-/* helpers */
-
-char *
-content_name (cairo_content_t content)
-{
- if (content == CAIRO_CONTENT_COLOR) return "rgb";
- if (content == CAIRO_CONTENT_COLOR_ALPHA) return "argb";
- if (content == CAIRO_CONTENT_ALPHA) return "a8";
- assert (0);
- return NULL;
-}
-
-cairo_content_t
-content_for_name (const char *content)
-{
- if (strcmp(content, "rgb") == 0) return CAIRO_CONTENT_COLOR;
- if (strcmp(content, "argb") == 0) return CAIRO_CONTENT_COLOR_ALPHA;
- if (strcmp(content, "a8") == 0) return CAIRO_CONTENT_ALPHA;
- return (cairo_content_t) -1;
-}
-
-/* timers */
-
-#ifdef USE_WINAPI
-void
-timer_start (bench_timer_t *tr) {
- QueryPerformanceCounter(&tr->start);
-}
-
-void
-timer_stop (bench_timer_t *tr) {
- QueryPerformanceCounter(&tr->stop);
-}
-
-double
-timer_elapsed (bench_timer_t *tr) {
- double d;
- LARGE_INTEGER freq;
-
- QueryPerformanceFrequency(&freq);
-
- d = (tr->stop.QuadPart - tr->start.QuadPart) / (double) freq.QuadPart;
- return d;
-}
-#else
-void
-timer_start (bench_timer_t *tr) {
- gettimeofday (&tr->start, NULL);
-}
-
-void
-timer_stop (bench_timer_t *tr) {
- gettimeofday (&tr->stop, NULL);
-}
-
-double
-timer_elapsed (bench_timer_t *tr) {
- double d;
-
- d = tr->stop.tv_sec - tr->start.tv_sec;
- d += (tr->stop.tv_usec - tr->start.tv_usec) / 1000000.0;
-
- return d;
-}
-#endif
-
-/* alarms */
-int test_seconds = -1;
-
-int alarm_expired = 0;
-
-#ifdef USE_WINAPI
-void CALLBACK
-alarm_handler (void *closure, DWORD dwTimerLowValue, DWORD dwTimerHighValue) {
- alarm_expired = 1;
-}
-
-HANDLE hTimer = NULL;
-void
-set_alarm (int seconds) {
- if (hTimer == NULL)
- hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
- alarm_expired = 0;
-
- LARGE_INTEGER expTime;
- expTime.QuadPart = - (seconds * 10000000);
- if (!SetWaitableTimer (hTimer, &expTime, 0, alarm_handler, &alarm_expired, FALSE))
- fprintf (stderr, "SetWaitableTimer failed!\n");
-}
-#else
-void
-alarm_handler (int signal) {
- if (signal == SIGALRM) {
- alarm_expired = 1;
- }
-}
-
-void
-set_alarm (int seconds) {
- alarm_expired = 0;
- signal (SIGALRM, alarm_handler);
- alarm (seconds);
-}
-#endif
-
-/* timers + alarms! */
-
-void
-start_timing (bench_timer_t *tr, long *count) {
- if (test_seconds == -1) {
- if (getenv("TEST_SECONDS"))
- test_seconds = strtol(getenv("TEST_SECONDS"), NULL, 0);
- else
- test_seconds = 5;
- }
- *count = 0;
- timer_start (tr);
- set_alarm (test_seconds);
-}
-
-void
-stop_timing (bench_timer_t *tr, long count) {
- timer_stop (tr);
- tr->count = count;
-}
-
-double
-timing_result (bench_timer_t *tr) {
- return tr->count / timer_elapsed (tr);
-}
More information about the cairo-commit
mailing list