[Interest] Qtcontainerbench std::vector vs QVector

André Somers andre at familiesomers.nl
Tue Jul 28 10:02:21 CEST 2015

Op 27-7-2015 om 21:42 schreef Gunnar Roth:
> Hi Constantin.
> Thank you for looking at my benchmark.
>> Am 24.07.2015 um 08:57 schrieb Constantin Makshin <cmakshin at gmail.com>:
>> Well, after looking at the code I can say that the was you wrote this
>> benchmark "abuses" the QVector's copy-on-write semantic, making it
>> somewhat biased towards std::vector — you use only non-const versions of
>> QVector::begin(), QVector::end() and indexing methods. That leads to a
>> lot of [obviously non-free] checks for sharing and possible detachment.
> Actually imo this is the most important case. Why should i iterate	over a vector and not change the values?
> If i search in a vector it should be sorted.
Not always true of course. You can only sort on one key. What if once in 
awhile I need to search on another key? If usually my Employee objects 
are in a vector sorted by id, I may still want to search by name once in 
awhile. Of course, if you need to search frequently on a key, sort by it.


More information about the Interest mailing list