f5fbd79b28a06aa90a8a0ece5dd1094334aa95e0
[bertos.git] / bertos / sec / benchmarks.c
1 #include "benchmarks.h"
2 #include <sec/hash.h>
3 #include <drv/timer.h>
4 #include <string.h>
5
6 void hash_benchmark(Hash *h, const char *hname, int numk)
7 {
8         static uint8_t buf[512];
9         memset(buf, 0x12, sizeof(buf));
10
11         ticks_t t = timer_clock();
12
13         for (int j=0;j<64;++j) {
14                 hash_begin(h);
15                 for (int i=0; i<numk*2; ++i)
16                         hash_update(h, buf, 512);
17                 hash_final(h);
18         }
19
20         t = timer_clock() - t;
21
22         utime_t usec = ticks_to_us(t) / 64;
23         kprintf("%s @ %ldMhz: %s of %dKiB of data: %lu.%lu ms\n", CPU_CORE_NAME, CPU_FREQ/1000000, hname, numk, (usec/1000), (usec % 1000));
24 }