libx52/util/x52_lookup_test.c

210 lines
2.4 KiB
C

/* Test program for checking lookup performance */
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "libx52util.h"
static const uint8_t * test_strings[] = {
"\x20",
"\x21",
"\x22",
"\x23",
"\x24",
"\x25",
"\x26",
"\x27",
"\x28",
"\x29",
"\x2a",
"\x2b",
"\x2c",
"\x2d",
"\x2e",
"\x2f",
"\x30",
"\x31",
"\x32",
"\x33",
"\x34",
"\x35",
"\x36",
"\x37",
"\x38",
"\x39",
"\x3a",
"\x3b",
"\x3c",
"\x3d",
"\x3e",
"\x3f",
"\x40",
"\x41",
"\x42",
"\x43",
"\x44",
"\x45",
"\x46",
"\x47",
"\x48",
"\x49",
"\x4a",
"\x4b",
"\x4c",
"\x4d",
"\x4e",
"\x4f",
"\x50",
"\x51",
"\x52",
"\x53",
"\x54",
"\x55",
"\x56",
"\x57",
"\x58",
"\x59",
"\x5a",
"\x5b",
"\x5d",
"\x5e",
"\x5f",
"\x60",
"\x61",
"\x62",
"\x63",
"\x64",
"\x65",
"\x66",
"\x67",
"\x68",
"\x69",
"\x6a",
"\x6b",
"\x6c",
"\x6d",
"\x6e",
"\x6f",
"\x70",
"\x71",
"\x72",
"\x73",
"\x74",
"\x75",
"\x76",
"\x77",
"\x78",
"\x79",
"\x7a",
"\x7b",
"\x7c",
"\x7d",
"\xc2\xa7",
"\xc2\xb6",
"\xc2\xa9",
"\xc2\xae",
"\xc2\xbd",
"\xc2\xbc",
"\xc3\x97",
"\xc3\xb7",
"\xe2\x89\xa4",
"\xe2\x89\xa5",
"\xe2\x89\xaa",
"\xe2\x89\xab",
"\xe2\x89\xa0",
"\xe2\x88\x9a",
"\xc3\x87",
"\xc3\xbc",
"\xc3\xa9",
"\xc3\xa2",
"\xc3\xa4",
"\xc3\xa0",
"\xc8\xa7",
"\xc3\xa7",
"\xc3\xaa",
"\xc3\xab",
"\xc3\xa8",
"\xc3\xaf",
"\xc3\xae",
"\xc3\xac",
"\xc3\x84",
"\xc3\x82",
"\xc3\x89",
"\xc3\xa6",
"\xc3\x86",
"\xc3\xb4",
"\xc3\xb6",
"\xc3\xb2",
"\xc3\xbb",
"\xc3\xb9",
"\xc3\xbf",
"\xc3\x96",
"\xc3\x9c",
"\xc3\xb1",
"\xc3\x91",
"\xc2\xaa",
"\xc2\xba",
"\xc2\xbf",
"\xc3\xa1",
"\xc3\xad",
"\xc3\xb3",
"\xc3\xba",
"\xc2\xa2",
"\xc2\xa3",
"\xc2\xa5",
"\xc2\xa1",
"\xc3\x83",
"\xc3\xa3",
"\xc3\x95",
"\xc3\xb5",
"\xc3\x98",
"\xc3\xb8",
"\xce\x93",
"\xce\x94",
"\xce\x98",
"\xce\x9b",
"\xce\x9e",
"\xce\xa0",
"\xce\xa3",
"\xcf\x92",
"\xce\xa6",
"\xce\xa8",
"\xce\xa9",
"\xce\xb1",
"\xe2\x94\x8c",
"\xe2\x94\x90",
"\xe2\x94\x94",
"\xe2\x94\x98",
"\xe2\x94\x80",
""
};
#define ROUNDS 10000000
int main()
{
int i;
int j;
const uint8_t * test_str = NULL;
uint8_t output[8];
size_t retval;
clock_t start, end;
start = clock();
for (i = 0; i < ROUNDS; i++) {
for (j = 0; ; j++) {
test_str = test_strings[j];
if (test_str[0] == 0) {
break;
}
/* Run the lookup function */
libx52util_convert_utf8_string(test_str, output, &retval);
}
}
end = clock();
printf("Perf test - time used %ld\n", end - start);
return 0;
}