![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an application that allocates a large number of strings using the String(byte[] bytes, int offset, int length) constructor. A simple test case shows that string allocation is between one and two orders of magnitude slower in J# relative to JVM 1.4. Here's the code: int dataLength = 200000; int numStrings = 6000; int strLength = 100; int offsetIncrement = (dataLength - strLength) / numStrings; byte[] data = new byte[dataLength]; new Random().nextBytes(data); String[] strs = new String[numStrings]; long start = System.currentTimeMillis(); int j = 0; for (int i = 0; i < numStrings; i++) { strs[i] = new String(data, j, strLength); j += offsetIncrement; } long end = System.currentTimeMillis(); long duration = end - start; System.out.println("Elapsed time: " + new Long(duration).toString()); JVM 1.4: 160 ms J#: 11086 ms Has anyone seen this before? FS |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |