Changeset 3572 for libcaca


Ignore:
Timestamp:
Jul 24, 2009, 8:49:01 AM (10 years ago)
Author:
Sam Hocevar
Message:

Use a dummy display to compute benchmark time to avoid relying on <time.h>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/tests/bench.c

    r3566 r3572  
    22
    33#include <stdio.h>
    4 #include <stdlib.h>
    5 #include <time.h>
    64
    75#include "caca.h"
    86
    9 
    10 #define TIME(desc,code) \
    11 {\
    12     time_t start, end;\
    13     start = time(NULL);\
    14     code ;\
    15     end = time(NULL);\
    16     printf("%-25s:%4ld\n", desc, end-start);\
     7#define TIME(desc, code) \
     8{ \
     9    caca_display_t *dummy = caca_create_display_with_driver(NULL, "null"); \
     10    printf("%-25s: ", desc);\
     11    caca_refresh_display(dummy); \
     12    code; \
     13    caca_refresh_display(dummy); \
     14    printf("%dms\n", caca_get_display_time(dummy) / 1000); \
     15    caca_free_display(dummy); \
    1716}
    1817
Note: See TracChangeset for help on using the changeset viewer.