开发者

is there a performance difference between QList<QList<int> >myList; and int ** myList;?

开发者 https://www.devze.com 2022-12-19 08:47 出处:网络
I would like to know if it is more efficien开发者_运维问答t to use a int ** than a QList > or if they are pretty much equal.I have to do alot of calculations so I might want to get to faster oneThe di

I would like to know if it is more efficien开发者_运维问答t to use a int ** than a QList > or if they are pretty much equal. I have to do alot of calculations so I might want to get to faster one


The difference in speed depends on the operations you are doing. QList is safer because it automatically allocates and deallocates its storage.

Worry about your program being correct first, then worry about performance, and always profile first before you optimize.


Here is a chart with complexity of Qt containers depending on their use case :

http://qt.nokia.com/doc/4.6/containers.html#algorithmic-complexity

Maybe it will help you !


If I refer to QList documentation:

Internally, QList is represented as an array of pointers to items of type T

Ref: http://qt.nokia.com/doc/4.6/qlist.html#details

So, it seems to be pretty equivalent. If you want to be sure, you can look at the source code or write a benchmark using QTestLib.

0

精彩评论

暂无评论...
验证码 换一张
取 消