Skip to content
Commit 9b35c827 authored by Howard Hinnant's avatar Howard Hinnant
Browse files

Dave Zarzycki showed how the efficiency of shared_ptr could be significantly

increased.  The following program is running 49% faster:

#include <iostream>
#include <memory>
#include <chrono>
#include <vector>
#include "chrono_io"

int main()
{
    typedef std::chrono::high_resolution_clock Clock;
    Clock::time_point t0 = Clock::now();
    {
        std::shared_ptr<int> p(new int (1));
        std::vector<std::shared_ptr<int> > v(1000000, p);
        v.insert(v.begin(), p);
        v.insert(v.begin(), p);
        v.insert(v.begin(), p);
        v.insert(v.begin(), p);
    }
    Clock::time_point t1 = Clock::now();
    std::cout << (t1-t0) << '\n';
}

llvm-svn: 119388
parent fced6e25
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment