The special case where deque
can be much faster than vector
is when you're inserting at the front of the container. In your case you're inserting at random locations, which will actually give the advantage to vector
.
Also unless you're using an optimized build, it's quite possible that there are bounds checks in the library implementation. Those checks can add significantly to the time. To do a proper benchmark comparison you must run with all normal optimizations turned on and debug turned off.