Original Post
🔒 Locked
speed prob
Advertisement
I'm not an expert on benchmarking, but I do know that it is very difficult to create fair benchmarks, especially across various languages; it takes a lot of experience to do it well. There could be all sorts of reasons why your code is turning out as it does. Is your C code compiled in debug or release mode? What optimizations might the C compiler do, or the .NET runtime? It might be able to tell that those loops are completely useless, if that data isn't actually used for something, and thus it wisely skips them entirely.
Try increasing or decreasing the numbers by a noticeable amount. If the VB code's speed doesn't seem affected, it very well may be just skipping the loops completely. But if the speed scales appropriately, then it must be something else. You could always try looking at the disassembly of the C++ code, or the byte code for the C#/VB.NET code, and see how they differ. Something's definitely up, 'cause you're right, 100 times slower for C++/C# doesn't sound correct. What I would expect would be almost identical speeds for a simple loop structure like that.
Try increasing or decreasing the numbers by a noticeable amount. If the VB code's speed doesn't seem affected, it very well may be just skipping the loops completely. But if the speed scales appropriately, then it must be something else. You could always try looking at the disassembly of the C++ code, or the byte code for the C#/VB.NET code, and see how they differ. Something's definitely up, 'cause you're right, 100 times slower for C++/C# doesn't sound correct. What I would expect would be almost identical speeds for a simple loop structure like that.
This is a shot in the dark, but maybe the languages handle nested loops differently. Try a similar test with only one loop:
You also have a small typo in the source you showed.
for(y=0; y<1000l y++)
should be:
for(y=0; y<1000; y++)
I assume you just did that in the post, since ?I doubt that would actually compile...
Make sure to check out all optimizations as well. Are you using the optimizing compiler for c++? Do you have it set for maximum speed? There are tons of little things you must make sure of when you run benchmarks.
Also, post the VB code just in case there is some discrepancy (like you forgot some zeros in the loop, so it was only 1/100 the length).
for(int i=0; i < 10000; i++) variable = 1;You also have a small typo in the source you showed.
for(y=0; y<1000l y++)
should be:
for(y=0; y<1000; y++)
I assume you just did that in the post, since ?I doubt that would actually compile...
Make sure to check out all optimizations as well. Are you using the optimizing compiler for c++? Do you have it set for maximum speed? There are tons of little things you must make sure of when you run benchmarks.
Also, post the VB code just in case there is some discrepancy (like you forgot some zeros in the loop, so it was only 1/100 the length).
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement