1 #include "benchmarks.h"
6 static uint8_t buf[512];
8 void hash_benchmark(Hash *h, const char *hname, int numk)
10 memset(buf, 0x12, sizeof(buf));
11 ticks_t t = timer_clock();
13 for (int j=0;j<64;++j) {
15 for (int i=0; i<numk*2; ++i)
16 hash_update(h, buf, 512);
20 t = timer_clock() - t;
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));
26 void prng_benchmark(PRNG *prng, const char *hname, int numbytes)
28 memset(buf, 0x12, sizeof(buf));
30 ASSERT(sizeof(buf) >= prng_seed_len(prng));
31 prng_reseed(prng, buf);
33 ticks_t t = timer_clock();
35 for (int j=0;j<2048;++j) {
36 for (int i=0; i<(numbytes+511)/512-1; ++i)
37 prng_generate(prng, buf, 512);
39 prng_generate(prng, buf, numbytes%512);
42 t = timer_clock() - t;
44 utime_t usec = ticks_to_us(t) / 2048;
45 kprintf("%s @ %ldMhz: %s generation of %d random bytes: %lu.%lu ms\n", CPU_CORE_NAME, CPU_FREQ/1000000, hname, numbytes, (usec/1000), (usec % 1000));
46 kprintf("Sample of random data:\n");
47 kdump(buf, MIN(numbytes, 64));