C++ and Java performance
this question is just speculative.I have the following implementation in C++:using namespace std;void testvector(int x){ vector<string> v; char aux[20]; int a = x * 2000; int z = a + 2000; string...
View ArticleAnswer by sepp2k for C++ and Java performance
It should help if you use Vector::reserve to reserve space for z elements in v before the loop (however the same thing should also speed up the java equivalent of this code).
View ArticleAnswer by Daniel Earwicker for C++ and Java performance
You have to be careful with performance tests because it's very easy to deceive yourself or not compare like with like.However, I've seen similar results comparing C# with C++, and there are a number...
View ArticleAnswer by Gustavo Muenz for C++ and Java performance
What are you actually trying to measure here? Putting ints into a vector?You can start by pre-allocating space into the vector with the know size of the vector:instead of:void testvector(int x){...
View ArticleAnswer by Mike Dunlavey for C++ and Java performance
In your inner loop, you are pushing ints into a string vector. If you just single-step that at the machine-code level, I'll bet you find that a lot of that time goes into allocating and formatting the...
View ArticleAnswer by vickirk for C++ and Java performance
To suggest why the performance both C++ and java differ it would essential to see source for both, I can see a number of performance issues in the C++, for some it would be useful to see if you were...
View ArticleAnswer by Robert Christie for C++ and Java performance
Hotspot optimises hot spots in code. Typically, anything that gets executed 10000 times it tries to optimise. For this code, after 5 iterations it will try and optimise the inner loop adding the...
View ArticleAnswer by alex tingle for C++ and Java performance
All your program does is print the numbers 0..9000 in steps of 1000. The calls to testvector() do nothing and can be eliminated. I suspect that your JVM notices this, and is essentially optimising the...
View ArticleAnswer by Konrad Rudolph for C++ and Java performance
In my box, this program gets executed in approx. 12 seconds; amazingly, I have a similar implementation in Java [using String and ArrayList] and it runs lot faster than my C++ application (approx. 2...
View ArticleAnswer by gnud for C++ and Java performance
Well, this is a pretty useless test that only measures allocation of small objects.That said, simple changes made me get the running time down from about 15 secs to about 4 secs. New version:typedef...
View Article