mirror of https://github.com/nirenjan/libx52.git
feat: Add benchmarking for libx52util-bmp-test
parent
569902be76
commit
a1098bc134
|
|
@ -34,3 +34,7 @@ libx52util_bmp_test = executable(
|
|||
test('libx52util-bmp-test', libx52util_bmp_test,
|
||||
protocol: 'tap',
|
||||
args: [util_char_map[1]])
|
||||
|
||||
benchmark('libx52util-bmp-bench', libx52util_bmp_test,
|
||||
protocol: 'tap',
|
||||
args: [util_char_map[1]])
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libx52util.h"
|
||||
|
|
@ -61,6 +62,11 @@ static void encode_utf8(uint32_t cp, uint8_t *out)
|
|||
}
|
||||
}
|
||||
|
||||
static double get_time_diff(struct timespec start, struct timespec end)
|
||||
{
|
||||
return (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1e9;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t input[8] = {0};
|
||||
|
|
@ -72,6 +78,8 @@ int main(int argc, char *argv[])
|
|||
uint8_t *expected_blob;
|
||||
bool smp_pages_ok;
|
||||
|
||||
struct timespec start, end;
|
||||
|
||||
// Argument check
|
||||
if (argc != 2) {
|
||||
puts("Bail out! Invalid number of arguments");
|
||||
|
|
@ -97,6 +105,8 @@ int main(int argc, char *argv[])
|
|||
// Check the 256 BMP Pages, plus the supplementary pages
|
||||
puts("1..257");
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
|
||||
for (uint32_t page = 0; page < 256; page++) {
|
||||
bool page_ok = true;
|
||||
|
||||
|
|
@ -141,6 +151,16 @@ int main(int argc, char *argv[])
|
|||
page + 1, page);
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
{
|
||||
double time_spent = get_time_diff(start, end);
|
||||
printf("# -- Benchmark results --\n");
|
||||
printf("# Total time for 64K lookups: %.4f seconds\n", time_spent);
|
||||
printf("# Throughput: %.2f Mchars/sec\n", (65536.0 / time_spent) / 1e6);
|
||||
|
||||
printf("# -----------------------\n");
|
||||
}
|
||||
|
||||
// Handle the supplementary pages
|
||||
smp_pages_ok = true;
|
||||
for (uint32_t smp = 0x1; smp <= 0x10; smp++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue