-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
blitter_bench.c
53 lines (36 loc) · 1014 Bytes
/
blitter_bench.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Lorenzo Loconte - loreloc
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "blitter.h"
#define BENCH_LENGTH 2000000
int main(int argc, char* argv[])
{
// crea il framebuffer in RGB565
uint16_t* framebuffer = calloc(SCREEN_WIDTH * SCREEN_HEIGHT, sizeof(uint16_t));
// crea lo sprite in BGRA8888
uint8_t* sprite = calloc(SPRITE_SIZE * SPRITE_SIZE * 4, sizeof(uint8_t));
// colora i buffer
for(uint32_t i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; ++i)
framebuffer[i] = 0x1234;
for(uint32_t i = 0; i < SPRITE_SIZE * SPRITE_SIZE; ++i)
{
sprite[i * 4 + 0] = 0x83; // alpha
sprite[i * 4 + 1] = 0xB5; // rosso
sprite[i * 4 + 2] = 0x73; // verde
sprite[i * 4 + 3] = 0x18; // blu
}
clock_t t1 = clock();
// esegui il blit
for(uint32_t i = 0; i < BENCH_LENGTH; ++i)
{
blitSprite(framebuffer, sprite, 320, 240);
}
clock_t t2 = clock();
printf("Elapsed time: %f seconds\n", (float)(t2 - t1) / CLOCKS_PER_SEC);
free(sprite);
free(framebuffer);
return 0;
}