1 // Copyright (C) 2003-2017 Free Software Foundation, Inc.
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
6 // Free Software Foundation; either version 3, or (at your option)
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
20 #include <testsuite_performance.h>
25 using namespace __gnu_test
;
28 resource_counter resource
;
29 char bufin
[] = "This was an attempt to bypass string construction just for test.";
30 char bufout
[sizeof(bufin
)];
33 const ctype
<char>& ct
= use_facet
<ctype
<char> >(loc
);
36 start_counters(time
, resource
);
37 for (long i
= 0; i
< 1000000000; ++i
)
38 ct
.narrow(i
% 128, '*');
39 stop_counters(time
, resource
);
40 report_performance(__FILE__
, "narrow", time
, resource
);
41 clear_counters(time
, resource
);
44 start_counters(time
, resource
);
45 for (long i
= 0; i
< 100000000; ++i
)
46 ct
.narrow(bufin
, bufin
+sizeof(bufin
), '*', bufout
);
47 stop_counters(time
, resource
);
48 report_performance(__FILE__
, "narrow_array", time
, resource
);
49 clear_counters(time
, resource
);
52 start_counters(time
, resource
);
53 for (long i
= 0; i
< 1000000000; ++i
)
55 stop_counters(time
, resource
);
56 report_performance(__FILE__
, "widen", time
, resource
);
57 clear_counters(time
, resource
);
60 start_counters(time
, resource
);
61 for (long i
= 0; i
< 100000000; ++i
)
62 ct
.widen(bufin
, bufin
+sizeof(bufin
), bufout
);
63 stop_counters(time
, resource
);
64 report_performance(__FILE__
, "widen_array", time
, resource
);