File: bug.cpp

package info (click to toggle)
stlport5 5.0.2-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,668 kB
  • ctags: 18,713
  • sloc: ansic: 54,244; cpp: 20,808; asm: 93; sh: 91; makefile: 21
file content (39 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <set>
#include <vector>
#include <iostream>
#include <boost/timer.hpp>
#include <boost/lexical_cast.hpp>

struct compare
{
    bool operator()(int* x, int* y)
        { return *x < *y; }
            
};

int main(int argc, char const* const argv[])
{
    std::size_t niters = argc < 2 ? 1000 : boost::lexical_cast<std::size_t>(argv[1]);
    
    boost::timer t;
    
    std::vector<int> v;
    for (int n = 0; n < niters; ++n)
    {
        v.insert(v.begin() + v.size()/2, n);
    }

    std::cout << "vector fill: " << t.elapsed() << std::endl;
    
    std::multiset<int*,compare> m;
    for (int n = 0; n < niters; ++n)
    {
        m.insert(&v[n]);
    }
    std::cout << "map fill 1: " << t.elapsed() << std::endl;
    for (int n = 0; n < niters; ++n)
    {
        m.insert(&v[n]);
    }
    std::cout << "map fill 2: " << t.elapsed() << std::endl;
}