]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2003-2022 Free Software Foundation, Inc. |
9a1349b9 PC |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
9a1349b9 PC |
7 | // any later version. |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
9a1349b9 | 17 | |
9a1349b9 PC |
18 | |
19 | #include <locale> | |
20 | #include <cwctype> | |
21 | #include <cstddef> | |
22 | #include <testsuite_performance.h> | |
23 | ||
24 | int main() | |
25 | { | |
26 | using namespace std; | |
27 | using namespace __gnu_test; | |
28 | ||
29 | time_counter time; | |
30 | resource_counter resource; | |
31 | const wchar_t str[] = | |
32 | L"Is this the real life?\n" | |
33 | L"Is this just fantasy?\n" | |
34 | L"Caught in a landslide\n" | |
35 | L"No escape from reality\n" | |
36 | L"Open your eyes\n" | |
37 | L"Look up to the skies and see\n" | |
38 | L"I'm just a poor boy\n" | |
39 | L"I need no sympathy\n" | |
40 | L"Because I'm easy come, easy go\n" | |
41 | L"Little high, little low" | |
42 | L"Anyway the wind blows\n" | |
43 | L"Doesn't really matter to me\n" | |
44 | L"To me\n" | |
45 | L" -- Queen\n"; | |
46 | const size_t len = sizeof(str) / sizeof(str[0]) - 1; | |
47 | ||
48 | locale loc; | |
49 | const ctype<wchar_t>& ct = use_facet<ctype<wchar_t> >(loc); | |
50 | ||
51 | // C | |
52 | wctype_t w = wctype("space"); | |
53 | start_counters(time, resource); | |
54 | for (int j = 0; j < 200000; ++j) | |
55 | { | |
56 | for (size_t i = 0; i < len; ++i) | |
57 | { | |
58 | iswctype(str[i], w); | |
59 | } | |
60 | } | |
61 | stop_counters(time, resource); | |
62 | report_performance(__FILE__, "C", time, resource); | |
63 | clear_counters(time, resource); | |
64 | ||
65 | // C++ | |
66 | start_counters(time, resource); | |
67 | for (int j = 0; j < 200000; ++j) | |
68 | { | |
69 | for (size_t i = 0; i < len; ++i) | |
70 | { | |
71 | ct.is(ctype_base::space, str[i]); | |
72 | } | |
73 | } | |
74 | stop_counters(time, resource); | |
75 | report_performance(__FILE__, "C++", time, resource); | |
76 | ||
77 | return 0; | |
78 | } |