source: libcaca/trunk/tests/bench.c @ 3566

Last change on this file since 3566 was 3566, checked in by Pascal Terjan, 11 years ago
  • Add some simple bench (part 2, add the interesting file)
  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1#include "config.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <time.h>
6
7#include "caca.h"
8
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);\
17}
18
19static void blit(int mask, int clear)
20{
21    caca_canvas_t *cv, *cv2;
22    int i;
23    cv = caca_create_canvas(40, 40);
24    cv2 = caca_create_canvas(16, 16);
25    caca_fill_box(cv2, 0, 0, 16, 16, 'x');
26    for (i=0; i<1000000; i++) {
27      if(clear)
28              caca_clear_canvas(cv);
29      caca_blit(cv, 1, 1, cv2, mask?cv2:NULL);
30    }
31    caca_free_canvas(cv);
32    caca_free_canvas(cv2);
33}
34
35static void putchars(void)
36{
37    caca_canvas_t *cv;
38    int i;
39    cv = caca_create_canvas(40, 40);
40    for (i=0; i<50000000; i++) {
41      caca_put_char(cv, 1, 1, 'x');
42      caca_put_char(cv, 1, 1, 'o');
43    }
44    caca_free_canvas(cv);
45}
46
47int main(int argc, char *argv[])
48{
49    TIME("blit no mask, no clear",blit(0, 0));
50    TIME("blit no mask, clear",blit(0, 1));
51    TIME("blit mask, no clear",blit(1, 0));
52    TIME("blit mask, clear",blit(1, 1));
53    TIME("putchars",putchars());
54    return 0;
55}
56
Note: See TracBrowser for help on using the repository browser.