[Interest] Qtcontainerbench std::vector vs QVector

Thiago Macieira thiago.macieira at intel.com
Mon Jul 27 23:06:28 CEST 2015


On Monday 27 July 2015 21:42:58 Gunnar Roth wrote:
> But the results show still a 50% better performance for std::vector when
> inserting and 2 times better performance when iteration non const. In the
> other cases QVector is on par with std::vector. So i still say choose
> QVector only when you really need the implicit sharing.

Note that the iteration itself has the exact same performance. The difference 
you're seeing is overhead only.

A sufficiently large vector (which can be as small as 10 items) or sufficiently 
complex action on iteration (a printf, for example) will completely offset the 
overhead.

Both QVector and std::vector from libc++ have the exact same type for the 
iterator and const_iterator

QVector:
    typedef T* iterator;
    typedef const T* const_iterator;

std::vector:
    typedef pointer                                  iterator;
    typedef const_pointer                            const_iterator;

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list