X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Fbenchmarks.c;h=d0e3cdfffaf8aaacc21d34c47c7508a41c10af10;hb=54fcc3ee93f64797c9ad129fc7a22672f43f6582;hp=f5fbd79b28a06aa90a8a0ece5dd1094334aa95e0;hpb=bef610f14930b50af370a0a582f904204285d084;p=bertos.git diff --git a/bertos/sec/benchmarks.c b/bertos/sec/benchmarks.c index f5fbd79b..d0e3cdff 100644 --- a/bertos/sec/benchmarks.c +++ b/bertos/sec/benchmarks.c @@ -1,13 +1,12 @@ #include "benchmarks.h" -#include #include #include +static uint8_t buf[512]; + void hash_benchmark(Hash *h, const char *hname, int numk) { - static uint8_t buf[512]; memset(buf, 0x12, sizeof(buf)); - ticks_t t = timer_clock(); for (int j=0;j<64;++j) { @@ -22,3 +21,60 @@ void hash_benchmark(Hash *h, const char *hname, int numk) utime_t usec = ticks_to_us(t) / 64; kprintf("%s @ %ldMhz: %s of %dKiB of data: %lu.%lu ms\n", CPU_CORE_NAME, CPU_FREQ/1000000, hname, numk, (usec/1000), (usec % 1000)); } + +void prng_benchmark(PRNG *prng, const char *hname, int numbytes) +{ + memset(buf, 0x12, sizeof(buf)); + + ASSERT(sizeof(buf) >= prng_seed_len(prng)); + prng_reseed(prng, buf); + + ticks_t t = timer_clock(); + enum { CYCLES = 2048 }; + + for (int j=0;j= cipher_key_len(c)); + cipher_set_key(c, buf); + + uint8_t iv[cipher_block_len(c)]; + memset(iv, 0, sizeof(iv)); + + ticks_t t = timer_clock(); + enum { CYCLES = 64 }; + + for (int j=0;j