Forums Register Login
ArrayDeque vs LinkedList as Queue

I found next line in ArrayDeque javadoc:

"This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue".

So, is there a way to check this statement?

System.currentTimeMillis() doesn't work at all: two runs in a row and two opposite results.

(1 like)
But System.currentTimeMillis() is working. That is a typical result when you try performance speeds. Before you try any timings, make sure to run several runs so not less than 10⁴ operations are done in succession. That will instigate the Just in Time compilation. Then take several different timings because it is quite common for apparently opposite timings to occur like that. Also alternate them: sometimes run AD first and sometimes LL.
Can you post your code so we can run some tests?
(1 like)
you should use a microbenchmark framework like JMH. It deals with very complex performance testing issues that require deep understanding of the JVM. Check out the samples to get an idea.

Norm Radder wrote:Can you post your code so we can run some tests?

To my surprise, when I deleted other methods from my TimeCounter class, it somehow started to run as it should = ArrayDeque is almost always faster than LinkedList.
Probably the problem was that before calculating AD vs LL, in the same code I was calculating ArrayList vs LinkedList, and it would made impact on the performance.

Could you help me please with the file attachment procedure? I can't do it neither with *.java files, nor *.zip
And can't find [spoiler] button to post it as a code.
There is a button above the input box labeled: Code
Post the code via copy and paste, select it and press the Code button.
And it should look like this:
I saw it, but there are three files so I think it's a bit strange to post it this way without spoilers. Anyway, here they are.

(1 like)
The first thing I see is the autoboxing of the double to Double:

Create a Double object to use instead using a double.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 1546 times.

All times above are in ranch (not your local) time.
The current ranch time is
May 26, 2018 01:57:44.