Archive

Posts Tagged ‘adt’

Benchmark of datastructures in c++

October 30th, 2009 Dennis Hedegaard No comments

Here are some test results from a simple benchmark using vector, list, queue and stack in the c++ stl:

The benchmarks are done on 40.000.000 structs with a string and an int.

With aggressive optimizations (-march=native -funroll-all-loops -fomit-frame-pointer -finline -O9 -ffast-math):

$ ./stacktest
5.59 seconds
$ ./linkedtest
8.05 seconds
$ ./queuetest
5.51 seconds
$ ./vectortest
10 seconds

Without aggressive optimizations:

$ ./stacktest
8.3 seconds
$ ./linkedtest
12.84 seconds
$ ./queuetest
7.82 seconds
$ ./vectortest
12.89 seconds

What’s noteworthy is that a queue and a stack is pretty close in performance, compared to a vector and list.

The code for the project is on git for now:

http://git.neo2k.dk/?p=sum_benchmark.git;a=summary

I’m using cmake for makefiles :>

Categories: C/C++, Languages Tags: , , ,