1 // Copyright (C) 2005-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/>.
22 #include <testsuite_performance.h>
28 using namespace __gnu_test
;
31 resource_counter resource
;
33 const char filename
[] = "tmp_perf_chars.txt";
34 const unsigned lines
= 200000;
35 const unsigned line_length
= 200;
37 char* line
= new char[line_length
+ 2];
41 memset(line
, 'x', line_length
);
42 line
[line_length
] = '\n';
43 line
[line_length
+ 1] = '\0';
45 ofstream
out(filename
);
46 for (unsigned i
= 0; i
< lines
; ++i
)
50 // operator>>(basic_istream<char>& __in, basic_string<char>& __str)
52 start_counters(time
, resource
);
53 for (int iter
= 0; iter
< 25; ++iter
)
55 ifstream
file(filename
);
58 while (file
>> string_line
);
60 stop_counters(time
, resource
);
61 report_performance(__FILE__
, "string&", time
, resource
);
62 clear_counters(time
, resource
);
65 // operator>>(basic_istream<char>& __in, char* __s)
67 start_counters(time
, resource
);
68 for (int iter
= 0; iter
< 25; ++iter
)
70 ifstream
file(filename
);
74 stop_counters(time
, resource
);
75 report_performance(__FILE__
, "char*", time
, resource
);
76 clear_counters(time
, resource
);