Java でランダム インデックスの実装を作成しています。これは、大規模なコーパスを処理し、個々のトークンのコンテキストとインデックス ベクトルを何らかの方法で格納する必要があります。HashMap は自然 (文字列 -> トークン オブジェクト) のように見えましたが、Xprof を実行すると、処理の大部分がトークンを HashMap に追加することに費やされているように見えます。
出力を正しく読んでいますか?これはなぜですか?また、スピードアップする方法はありますか?
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