Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Given that you are not saying how you are measuring the elapsed time, I am assuming that you are using something like:</p> <pre><code>time java org.egge.concurrent.SerialTest &lt; in.gz &gt; out.gz time java org.egge.concurrent.ConcurrentQueueTest &lt; in.gz &gt; out.gz </code></pre> <p>The problem with this is that you are measuring two things here:</p> <ol> <li>How long the JVM takes to start up, and</li> <li>How long the program takes to run.</li> </ol> <p>You can only change the second one with your code changes. Using the figures that you gave:</p> <pre><code>Testing SerialTest real 0m6.736s user 0m6.924s sys 0m0.245s Testing ParallelExchangerTest real 0m4.967s user 0m7.491s sys 0m0.850s </code></pre> <p>If we assume that the JVM startup takes three seconds, then the "program run time" is 3.7 and 1.9 seconds respectively, this is pretty much a 100% speedup. I would strongly suggest that you use a larger dataset to test with so that you can minimise the impact of the startup of the JVM on your timing results.</p> <p><b>Edit</b>: Based on your answers to this question, you may well be suffering from lock contention. The best way to resolve that in java is probably to use the piped readers and writers, read from the pipes, byte at a time, and replace any <code>'@'</code> characters in the input stream with a <code>"_at_"</code> in the output stream. You might be suffering from the fact that each string is scanned three times, and any replacement requires a new object to be built, and the string ends up getting copied again. Hope this helps... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload