Blame pixman/pixman-timer.c

Packit 030a23
/*
Packit 030a23
 * Copyright © 2007 Red Hat, Inc.
Packit 030a23
 *
Packit 030a23
 * Permission to use, copy, modify, distribute, and sell this software and its
Packit 030a23
 * documentation for any purpose is hereby granted without fee, provided that
Packit 030a23
 * the above copyright notice appear in all copies and that both that
Packit 030a23
 * copyright notice and this permission notice appear in supporting
Packit 030a23
 * documentation, and that the name of Red Hat not be used in advertising or
Packit 030a23
 * publicity pertaining to distribution of the software without specific,
Packit 030a23
 * written prior permission.  Red Hat makes no representations about the
Packit 030a23
 * suitability of this software for any purpose.  It is provided "as is"
Packit 030a23
 * without express or implied warranty.
Packit 030a23
 *
Packit 030a23
 * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
Packit 030a23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
Packit 030a23
 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
Packit 030a23
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
Packit 030a23
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
Packit 030a23
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Packit 030a23
 */
Packit 030a23
Packit 030a23
#ifdef HAVE_CONFIG_H
Packit 030a23
#include <config.h>
Packit 030a23
#endif
Packit 030a23
Packit 030a23
#include <stdlib.h>
Packit 030a23
#include <stdio.h>
Packit 030a23
#include "pixman-private.h"
Packit 030a23
Packit 030a23
#ifdef PIXMAN_TIMERS
Packit 030a23
Packit 030a23
static pixman_timer_t *timers;
Packit 030a23
Packit 030a23
static void
Packit 030a23
dump_timers (void)
Packit 030a23
{
Packit 030a23
    pixman_timer_t *timer;
Packit 030a23
Packit 030a23
    for (timer = timers; timer != NULL; timer = timer->next)
Packit 030a23
    {
Packit 030a23
	printf ("%s:   total: %llu     n: %llu      avg: %f\n",
Packit 030a23
	        timer->name,
Packit 030a23
	        timer->total,
Packit 030a23
	        timer->n_times,
Packit 030a23
	        timer->total / (double)timer->n_times);
Packit 030a23
    }
Packit 030a23
}
Packit 030a23
Packit 030a23
void
Packit 030a23
pixman_timer_register (pixman_timer_t *timer)
Packit 030a23
{
Packit 030a23
    static int initialized;
Packit 030a23
Packit 030a23
    int atexit (void (*function)(void));
Packit 030a23
Packit 030a23
    if (!initialized)
Packit 030a23
    {
Packit 030a23
	atexit (dump_timers);
Packit 030a23
	initialized = 1;
Packit 030a23
    }
Packit 030a23
Packit 030a23
    timer->next = timers;
Packit 030a23
    timers = timer;
Packit 030a23
}
Packit 030a23
Packit 030a23
#endif