Note that there are some explanatory texts on larger screens.

plurals
  1. POIs HashMap.put for String keys generally a bottleneck? How do I speed it up?
    primarykey
    data
    text
    <p>I'm writing a <a href="http://en.wikipedia.org/wiki/Random_indexing" rel="nofollow">Random Indexing</a> implementation in Java, which needs to process large corpora and somehow store individual tokens' context and index vectors. A HashMap seemed natural (String -> Token object), but when running Xprof it seems like a disproportionate large portion of the processing goes to adding the token to the HashMap.</p> <p>Am I reading the output correctly? Why is this, and is there some way for me to speed things up?</p> <pre><code>Flat profile of 16.18 secs (606 total ticks): main Interpreted + native Method 6.9% 0 + 42 java.io.FileInputStream.readBytes 5.0% 0 + 30 java.lang.Object.getClass 1.8% 11 + 0 java.lang.String.toLowerCase 1.5% 9 + 0 java.util.HashMap.resize 1.3% 8 + 0 opennlp.tools.tokenize.AbstractTokenizer.tokenize 1.3% 0 + 8 java.util.zip.ZipFile.read 1.2% 0 + 7 java.util.zip.ZipFile.open 0.8% 5 + 0 java.util.Arrays.copyOfRange 0.5% 0 + 3 java.io.FileInputStream.available 0.3% 2 + 0 java.util.HashMap.put 0.3% 0 + 2 sun.misc.Unsafe.compareAndSwapLong 0.3% 2 + 0 java.lang.CharacterDataLatin1.toLowerCase 0.3% 2 + 0 java.util.ArrayList.grow 0.3% 2 + 0 semanticspace.SparseVector.get 0.3% 2 + 0 java.lang.CharacterData.of 0.2% 1 + 0 java.util.HashMap.createEntry 0.2% 1 + 0 java.util.Arrays.copyOf 0.2% 1 + 0 java.lang.Integer.valueOf 0.2% 1 + 0 java.lang.Integer.toString 0.2% 1 + 0 sun.misc.JarIndex.addToList 0.2% 1 + 0 java.util.ArrayList.toArray 0.2% 1 + 0 java.net.URL.toString 0.2% 1 + 0 semanticspace.SparseVector.add 0.2% 1 + 0 sun.reflect.NativeMethodAccessorImpl.invoke0 0.2% 1 + 0 java.io.BufferedInputStream.read1 26.2% 65 + 94 Total interpreted (including elided) Compiled + native Method 36.5% 217 + 4 java.util.HashMap.put 24.3% 133 + 14 semanticspace.SparseVector.add 2.6% 15 + 1 semanticspace.RandomIndexing.getToken 1.3% 8 + 0 java.lang.String.toLowerCase 1.3% 8 + 0 semanticspace.RandomIndexing.read 0.5% 0 + 3 java.util.HashMap.newKeyIterator 0.2% 0 + 1 semanticspace.SparseVector.get 0.2% 1 + 0 java.util.HashMap.containsKey 66.8% 382 + 23 Total compiled Stub + native Method 6.9% 0 + 42 java.lang.System.arraycopy 6.9% 0 + 42 Total stub Flat profile of 0.00 secs (1 total ticks): DestroyJavaVM Thread-local ticks: 100.0% 1 Blocked (of total) Flat profile of 16.17 secs (608 total ticks): Monitor Ctrl-Break Interpreted + native Method 98.2% 0 + 597 java.net.PlainSocketImpl.socketAccept 1.0% 0 + 6 java.net.PlainSocketImpl.initProto 0.7% 0 + 4 java.net.NetworkInterface.getAll 0.2% 0 + 1 java.lang.ClassLoader$NativeLibrary.load 100.0% 0 + 608 Total interpreted Global summary of 16.33 seconds: 100.0% 1326 Received ticks 53.2% 706 Received GC ticks 6.8% 90 Compilation 0.1% 1 Other VM operations </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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