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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libstdc++-v3/] [testsuite/] [performance/] [25_algorithms/] [search_n.cc] - Blame information for rev 519

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
#define DISABLE_ITERATOR_DEBUG 1
20
 
21
#include<cstdlib>
22
#include<vector>
23
#include<algorithm>
24
 
25
#include<sstream>
26
#include<testsuite_performance.h>
27
#include<testsuite_iterators.h>
28
 
29
using namespace std;
30
using namespace __gnu_test;
31
 
32
const int length = 10000000;
33
const int match_length = 3;
34
int array[length];
35
 
36
int
37
main(void)
38
{
39
  time_counter time;
40
  resource_counter resource;
41
  int match = rand() % (match_length - 1);
42
  for(int i = 0; i < length; i++)
43
    {
44
      array[i] = (match != 0) ? 1 : 0;
45
      if(--match < 0) match = rand() % (match_length - 1);
46
    }
47
  __gnu_test::test_container<int, forward_iterator_wrapper> fcon(array, array + length);
48
  start_counters(time, resource);
49
  for(int i = 0; i < 100; i++)
50
    search_n(fcon.begin(), fcon.end(), 10, 1);
51
  stop_counters(time, resource);
52
  report_performance(__FILE__, "forward iterator", time, resource);
53
  clear_counters(time, resource);
54
 
55
  __gnu_test::test_container<int, random_access_iterator_wrapper> rcon(array, array + length);
56
  start_counters(time, resource);
57
  for(int i = 0; i < 100; i++)
58
    search_n(rcon.begin(), rcon.end(), 10, 1);
59
  stop_counters(time, resource);
60
  report_performance(__FILE__, "random acess iterator", time, resource);
61
  clear_counters(time, resource);
62
}
63
 

powered by: WebSVN 2.1.0

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