genericopenlibs/cppstdlib/stl/test/eh/bug.cpp
author William Roberts <williamr@symbian.org>
Tue, 22 Jun 2010 22:03:38 +0100
branchGCC_SURGE
changeset 39 4393da0c39b5
parent 18 47c74d1534e1
child 45 4b03adbd26ca
child 71 28ccaba883f4
permissions -rw-r--r--
Fix IMPORT_C/EXPORT_C mismatches in bsul and openenvcore/backend - Bug 2971

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/

#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;
}