1 // Copyright (C) 2004, 2009 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/>.
19 #define DISABLE_ITERATOR_DEBUG 1
26 #include<testsuite_performance.h>
27 #include<testsuite_iterators.h>
30 using namespace __gnu_test
;
32 const int length
= 10000000;
33 const int match_length
= 3;
40 resource_counter resource
;
41 int match
= rand() % (match_length
- 1);
42 for(int i
= 0; i
< length
; i
++)
44 ary
[i
] = (match
!= 0) ? 1 : 0;
45 if(--match
< 0) match
= rand() % (match_length
- 1);
47 __gnu_test::test_container
<int, forward_iterator_wrapper
> fcon(ary
, ary
+ 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
);
55 __gnu_test::test_container
<int, random_access_iterator_wrapper
> rcon(ary
, ary
+ 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
);