]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/performance/27_io/fmtflags_manipulators.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / performance / 27_io / fmtflags_manipulators.cc
1 // Copyright (C) 2004-2014 Free Software Foundation, Inc.
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
6 // Free Software Foundation; either version 3, or (at your option)
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
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18
19 #include <cstdlib>
20 #include <sstream>
21 #include <testsuite_performance.h>
22
23 // libstdc++/14078
24 int main(int argc, char** argv)
25 {
26 using namespace std;
27 using namespace __gnu_test;
28
29 time_counter time;
30 resource_counter resource;
31
32 int iters = 50000000;
33 if (argc > 1)
34 iters = atoi(argv[1]);
35
36 ostringstream os_s, os_m;
37
38 // setf
39 start_counters(time, resource);
40 for (int i = 0; i < iters; ++i)
41 {
42 os_s.setf(ios_base::uppercase);
43 os_s.unsetf(ios_base::uppercase);
44 }
45 stop_counters(time, resource);
46 report_performance(__FILE__, "setf", time, resource);
47 clear_counters(time, resource);
48
49 // manipulator
50 start_counters(time, resource);
51 for (int i = 0; i < iters; ++i)
52 {
53 os_m << uppercase;
54 os_m << nouppercase;
55 }
56 stop_counters(time, resource);
57 report_performance(__FILE__, "manipulator", time, resource);
58
59 return 0;
60 }