Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Java vs C++ speed (IO & Sorting)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Razii, post: 3495865"] How are you comparing that with Java? I can change the function in Java too :) After changes,, the new times I am getting on java are.. C:\>java -Xmx256m -server Find a Number of a: 1929940 Time: 956 ms C:\>java -Xmx256m -server Find z Number of z: 1833020 Time: 925 ms C:\>java -Xmx256m -server Find p Number of p: 1930647 Time: 908 ms The randomness is pretty good except for z and y which are slightly lower .. That time is 2 times faster than the last java version... static String randomString(int len) { int i, n; char[] cr = new char[len]; Random rd = new Random(); for(i = 0 ; i < len; i+=4) { n = rd.nextInt(2147483647); cr[i] = (char) (n % 26 + 97); cr[i+1] = (char) ( (n>>8) % 26 + 97); cr[i+2] = (char) ( (n>>16) % 26 + 97); cr[i+3] = (char) ( (n>>24) % 26 + 97); } return new String(cr); }[/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Java vs C++ speed (IO & Sorting)
Top