-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_benchmark.c
68 lines (55 loc) · 1.39 KB
/
test_benchmark.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdint.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include "benchmark.h"
#include "asmheap.h"
#include "cheap.h"
#include "test_data.h"
#include "test_benchmark.h"
void test_benchmark_asmheap(void) {
static uint8_t i, j;
cputs(" Asm heap 100 * 128 push/pop: ");
asmheap_init();
benchmark_init();
benchmark_start();
for (j = 0; j < 100; ++j) {
for (i = 0; i < 128; ++i) {
asmheap_push(test_data_random[i]);
}
for (i = 0; i < 128; ++i) {
asmheap_pop();
}
}
benchmark_stop();
cprintf("%3d.%02d\r\n",
benchmark_result() / 100,
benchmark_result() % 100);
benchmark_exit();
}
void test_benchmark_cheap(void) {
static uint8_t i, j;
cputs(" C heap 100 * 128 push/pop: ");
cheap_init();
benchmark_init();
benchmark_start();
for (j = 0; j < 100; ++j) {
for (i = 0; i < 128; ++i) {
cheap_push(test_data_random[i]);
}
for (i = 0; i < 128; ++i) {
cheap_pop();
}
}
benchmark_stop();
cprintf("%3d.%02d\r\n",
benchmark_result() / 100,
benchmark_result() % 100);
benchmark_exit();
}
void test_benchmark(void) {
cputs("Benchmarks:\r\n");
test_benchmark_asmheap();
test_benchmark_cheap();
cputs("\r\n");
}