case.c - libgrapheme - unicode string library | |
git clone git://git.suckless.org/libgrapheme | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
case.c (1194B) | |
--- | |
1 /* See LICENSE file for copyright and license details. */ | |
2 #include <errno.h> | |
3 #include <math.h> | |
4 #include <stdint.h> | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
8 | |
9 #include "../gen/word-test.h" | |
10 #include "../grapheme.h" | |
11 #include "util.h" | |
12 | |
13 #define NUM_ITERATIONS 10000 | |
14 | |
15 struct break_benchmark_payload { | |
16 uint_least32_t *src; | |
17 size_t srclen; | |
18 uint_least32_t *dest; | |
19 size_t destlen; | |
20 }; | |
21 | |
22 void | |
23 libgrapheme(const void *payload) | |
24 { | |
25 const struct break_benchmark_payload *p = payload; | |
26 | |
27 grapheme_to_uppercase(p->src, p->srclen, p->dest, p->destlen); | |
28 } | |
29 | |
30 int | |
31 main(int argc, char *argv[]) | |
32 { | |
33 struct break_benchmark_payload p; | |
34 double baseline = (double)NAN; | |
35 | |
36 (void)argc; | |
37 | |
38 if ((p.src = generate_cp_test_buffer(word_break_test, | |
39 LEN(word_break_test), | |
40 &(p.srclen))) == NULL) { | |
41 return 1; | |
42 } | |
43 if ((p.dest = calloc((p.destlen = 2 * p.srclen), sizeof(*(p.dest… | |
44 NULL) { | |
45 fprintf(stderr, "calloc: Out of memory\n"); | |
46 } | |
47 | |
48 printf("%s\n", argv[0]); | |
49 run_benchmark(libgrapheme, &p, "libgrapheme ", NULL, "codepoint", | |
50 &baseline, NUM_ITERATIONS, p.srclen - 1); | |
51 | |
52 free(p.src); | |
53 free(p.dest); | |
54 | |
55 return 0; | |
56 } |