1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <ctype.h>
18 
19 #include <benchmark/benchmark.h>
20 #include "util.h"
21 
22 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y1, isalnum('A'));
23 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y2, isalnum('a'));
24 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y3, isalnum('0'));
25 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_n, isalnum('_'));
26 
27 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_y1, isalpha('A'));
28 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_y2, isalpha('a'));
29 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_n, isalpha('_'));
30 
31 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isascii_y, isascii('x'));
32 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isascii_n, isascii(0x88));
33 
34 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_y1, isblank(' '));
35 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_y2, isblank('\t'));
36 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_n, isblank('_'));
37 
38 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_y1, iscntrl('\b'));
39 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_y2, iscntrl('\x7f'));
40 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_n, iscntrl('_'));
41 
42 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isdigit_y, iscntrl('0'));
43 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isdigit_n, iscntrl('_'));
44 
45 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y1, isgraph('A'));
46 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y2, isgraph('a'));
47 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y3, isgraph('0'));
48 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y4, isgraph('_'));
49 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_n, isgraph(' '));
50 
51 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_islower_y, islower('x'));
52 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_islower_n, islower('X'));
53 
54 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y1, isprint('A'));
55 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y2, isprint('a'));
56 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y3, isprint('0'));
57 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y4, isprint('_'));
58 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y5, isprint(' '));
59 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_n, isprint('\b'));
60 
61 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_ispunct_y, ispunct('_'));
62 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_ispunct_n, ispunct('A'));
63 
64 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_y1, isspace(' '));
65 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_y2, isspace('\t'));
66 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_n, isspace('A'));
67 
68 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isupper_y, isupper('X'));
69 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isupper_n, isupper('x'));
70 
71 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y1, isxdigit('0'));
72 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y2, isxdigit('a'));
73 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y3, isxdigit('A'));
74 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_n, isxdigit('_'));
75 
76 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toascii_y, isascii('x'));
77 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toascii_n, isascii(0x88));
78 
79 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_tolower_y, tolower('X'));
80 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_tolower_n, tolower('x'));
81 
82 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toupper_y, toupper('x'));
83 BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toupper_n, toupper('X'));
84