W3bbo wrote:
 |
TimP wrote:
Perhaps gcc is performing optimizations that VC++ is not. Try compiling them both with no optimizations and test the run times. If they're equivalent, then gcc is optimizing more aggressively, otherwise the culprit is elsewhere. |
Optimizations are good... but I'd never expect a 50% gain in performance with them.
Depends on the program. Some programs simply can't be optimised, others can get a 90% improvement using cheap optimisations. In general debug optimisations give a 7% increase in speed but take up more memory, semi-release optimisations get an about 20% improvement
and a full-optimisation for final release is about 25-40% speed-up.
Shining Arcanine wrote:
Bounds checking? C is not supposed to have bounds checking. That is a Java feature.
Bounds checking could be related is related to the Buffer Security Check, which I have disabled. I am not sure if there are any other features that Microsoft put into its compiler that would do this sort of checking. Is anyone from the Visual Studio team reading
this thread and do you have anything to say about any of the things mentioned in the thread?
Bounds checking in C is hard, but possible, and actually happens in lots of modern C compilers (including GCC and VC++). With static arrays it's easy:
int c[100];
for(int i=0;i<
=100;i++){
if(i > 100) #error // inserted by the compiler. c[i] = i;
}
Will error when you build the flow graph. With dynamically allocated memory it's more expensive:
int * myArray = calloc(100, sizeof(int));
for(int i=0;i<=100;i++){
myArray[i] = i;
}
int * myArray = calloc(100, sizeof(int));
for(int i=0;i<=100;i++){
int __cptr = (int)myArray + sizeof(int) * i;
if(malloc_index(__cptr) == -1 || malloc_index(myArray) != malloc_index(__cptr)) #error
*__cptr = i;}
where malloc_index looks through the malloc table (
O(log n)) and returns the index in the table that corresponds to the pointer.
Shining Arcanine wrote:
Not when you consider the fact that there is no analogous measurement method available on Windows.
I would have to write a time program myself and I have other things to do.
You should do the test many times:
float f;
int i, time;
setup_low_resolution_timer();
for(i=0;i<1000;i++){
do_function();
}
time = stop_low_resolution_timer();
f = ((float)time / 1000);
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.