Fix miscompilation of 416.gamess.
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / performance / 21_strings / string_find.cc
blobeeda0802b3fb5d86b5d6372409fc62fb98e81ca4
1 // Copyright (C) 2004, 2009 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.
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/>.
19 #include <string>
20 #include <testsuite_performance.h>
22 void
23 test_pair(const std::string& s, const std::string& f, int n)
25 std::string::size_type sz = 0;
27 for (int i = 0; i < n; ++i)
28 sz = s.find(f);
31 int main()
33 using namespace std;
34 using namespace __gnu_test;
36 time_counter time;
37 resource_counter resource;
39 const unsigned int iterations = 2000000;
41 string s, f;
42 s = "aabbaabbaaxd adbffdadgaxaabbbddhatyaaaabbbaabbaabbcsy";
43 f = "aabbaabbc";
44 start_counters(time, resource);
45 test_pair(s, f, iterations);
46 stop_counters(time, resource);
47 report_performance(__FILE__, "1", time, resource);
48 clear_counters(time, resource);
50 f = "aabbb";
51 start_counters(time, resource);
52 test_pair(s, f, iterations);
53 stop_counters(time, resource);
54 report_performance(__FILE__, "2", time, resource);
55 clear_counters(time, resource);
57 f = "xd";
58 start_counters(time, resource);
59 test_pair(s, f, iterations);
60 stop_counters(time, resource);
61 report_performance(__FILE__, "3", time, resource);
62 clear_counters(time, resource);
64 s = "dhruv is a very very good boy ;-)";
65 f = "very";
66 start_counters(time, resource);
67 test_pair(s, f, iterations);
68 stop_counters(time, resource);
69 report_performance(__FILE__, "4", time, resource);
70 clear_counters(time, resource);
72 f = "bad";
73 start_counters(time, resource);
74 test_pair(s, f, iterations);
75 stop_counters(time, resource);
76 report_performance(__FILE__, "5", time, resource);
77 clear_counters(time, resource);
79 f = "extra irritating";
80 start_counters(time, resource);
81 test_pair(s, f, iterations);
82 stop_counters(time, resource);
83 report_performance(__FILE__, "6", time, resource);
84 clear_counters(time, resource);
86 s = "this is a very this is a very this is a verty this is a very "
87 "this is a very long sentence";
88 f = "this is a very long sentence";
89 start_counters(time, resource);
90 test_pair(s, f, iterations);
91 stop_counters(time, resource);
92 report_performance(__FILE__, "7", time, resource);
93 clear_counters(time, resource);
95 return 0;