]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2003-2023 Free Software Foundation, Inc. |
e3c0c098 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) |
e3c0c098 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/>. | |
e3c0c098 | 17 | |
e3c0c098 PC |
18 | |
19 | #include <locale> | |
20 | #include <testsuite_performance.h> | |
21 | ||
22 | int main() | |
23 | { | |
24 | using namespace std; | |
25 | using namespace __gnu_test; | |
26 | ||
27 | time_counter time; | |
28 | resource_counter resource; | |
9a1349b9 | 29 | wchar_t bufwc[] = L"Mi innamoravo di tutto (Fabrizio De Andre')"; |
ca13fb7f | 30 | char bufc[sizeof(bufwc) / sizeof(wchar_t)]; |
e3c0c098 PC |
31 | |
32 | locale loc; | |
33 | const ctype<wchar_t>& ct = use_facet<ctype<wchar_t> >(loc); | |
34 | ||
35 | // narrow | |
36 | start_counters(time, resource); | |
ca13fb7f | 37 | for (long i = 0; i < 200000000; ++i) |
e3c0c098 PC |
38 | ct.narrow(i % 128, '*'); |
39 | stop_counters(time, resource); | |
40 | report_performance(__FILE__, "narrow", time, resource); | |
41 | clear_counters(time, resource); | |
42 | ||
ca13fb7f PC |
43 | // narrow array |
44 | start_counters(time, resource); | |
45 | for (long i = 0; i < 20000000; ++i) | |
46 | ct.narrow(bufwc, bufwc + sizeof(bufwc) / sizeof(wchar_t), '*', bufc); | |
47 | stop_counters(time, resource); | |
48 | report_performance(__FILE__, "narrow array", time, resource); | |
49 | clear_counters(time, resource); | |
50 | ||
e3c0c098 PC |
51 | // widen |
52 | start_counters(time, resource); | |
ca13fb7f | 53 | for (long i = 0; i < 200000000; ++i) |
e3c0c098 PC |
54 | ct.widen(i % 128); |
55 | stop_counters(time, resource); | |
56 | report_performance(__FILE__, "widen", time, resource); | |
b1660ae9 | 57 | clear_counters(time, resource); |
e3c0c098 | 58 | |
ca13fb7f PC |
59 | // widen array |
60 | start_counters(time, resource); | |
61 | for (long i = 0; i < 20000000; ++i) | |
62 | ct.widen(bufc, bufc + sizeof(bufc), bufwc); | |
63 | stop_counters(time, resource); | |
64 | report_performance(__FILE__, "widen array", time, resource); | |
65 | ||
e3c0c098 PC |
66 | return 0; |
67 | } |