1 // Copyright (C) 2006-2024 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>
28 using namespace __gnu_test
;
30 typedef istreambuf_iterator
<char> in_iterator_type
;
31 typedef ostreambuf_iterator
<char> out_iterator_type
;
34 resource_counter resource
;
36 const char data
[] = "Contrappunto dialettico alla mente";
38 // istreambuf iterators -> ostreambuf iterator
40 istringstream
iss(data
);
41 in_iterator_type
beg(iss
);
45 out_iterator_type
out(oss
);
47 start_counters(time
, resource
);
48 for (unsigned i
= 0; i
< 10000000; ++i
)
54 stop_counters(time
, resource
);
55 report_performance(__FILE__
, "isb iters -> osb iter", time
, resource
);
56 clear_counters(time
, resource
);
59 // char array -> ostreambuf iterator
61 const char* beg
= data
;
62 const char* end
= data
+ sizeof(data
) - 1;
65 out_iterator_type
out(oss
);
67 start_counters(time
, resource
);
68 for (unsigned i
= 0; i
< 10000000; ++i
)
73 stop_counters(time
, resource
);
74 report_performance(__FILE__
, "pointers -> osb iter", time
, resource
);
75 clear_counters(time
, resource
);
78 // istreambuf iterators -> char array
80 istringstream
iss(data
);
81 in_iterator_type
beg(iss
);
84 char out
[sizeof(data
)];
86 start_counters(time
, resource
);
87 for (unsigned i
= 0; i
< 10000000; ++i
)
92 stop_counters(time
, resource
);
93 report_performance(__FILE__
, "isb iters -> pointer", time
, resource
);
94 clear_counters(time
, resource
);