1 // Copyright (C) 2003-2014 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/>.
22 #include <testsuite_performance.h>
27 test_append_char(int how_much
)
29 string buf
; // no preallocation
30 for (int i
= 0; i
< how_much
; ++i
)
31 buf
.append(static_cast<string::size_type
>(1) , 'x');
35 test_append_string(int how_much
)
37 string
s(static_cast<string::size_type
>(1) , 'x');
38 string buf
; // no preallocation
39 for (int i
= 0; i
< how_much
; ++i
)
44 run_benchmark1(int how_much
)
46 using namespace __gnu_test
;
48 resource_counter resource
;
49 start_counters(time
, resource
);
50 test_append_char(how_much
);
51 stop_counters(time
, resource
);
52 report_performance(__FILE__
, "char", time
, resource
);
56 run_benchmark2(int how_much
)
58 using namespace __gnu_test
;
60 resource_counter resource
;
61 start_counters(time
, resource
);
62 test_append_string(how_much
);
63 stop_counters(time
, resource
);
64 report_performance(__FILE__
, "string", time
, resource
);
71 run_benchmark1(100000);
72 run_benchmark2(100000);
73 run_benchmark1(1000000);
74 run_benchmark2(1000000);
75 run_benchmark1(10000000);
76 run_benchmark2(10000000);