OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [performance/] [21_strings/] [string_find.cc] - Blame information for rev 847

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
 // 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.
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 <string>
20
#include <testsuite_performance.h>
21
 
22
void
23
test_pair(const std::string& s, const std::string& f, int n)
24
{
25
  std::string::size_type sz = 0;
26
 
27
  for (int i = 0; i < n; ++i)
28
    sz = s.find(f);
29
}
30
 
31
int main()
32
{
33
  using namespace std;
34
  using namespace __gnu_test;
35
 
36
  time_counter time;
37
  resource_counter resource;
38
 
39
  const unsigned int iterations = 2000000;
40
 
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);
49
 
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);
56
 
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);
63
 
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);
71
 
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);
78
 
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);
85
 
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);
94
 
95
  return 0;
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.