I just want a simple function that I can call twice per run of my program that will return the time in milliseconds so I can make my programs more efficient. When I run the program I end up getting some small decimal (.002 ms to .0017 ms ish). Similar programs on ProjectEuler.net have gotten around 15 to 14 milliseconds. I know that I’m a skilled programmer (sarcasm) and all… The stuff between lines 13 and 27 can be ignored; I only included that section for reference. Any explanation for such a small output would be greatly appreciated, as having a handy little function like this at my disposal would really help make my coding more efficient.
There's a bug in your formula for calculating sigma(i=[1;n])(i).
n/2*(n+1) works only if n is a float. If n is an integer, the integer division messes up the result for n%2!=0:
3/2==1, so 3/2*(3+1)==4, but 1+2+3==6
(n*n+n)/2 works regardless of the type of n.
You can also google around "QueryPerformanceTimer" for more information. I am not saying that you shouldn't use it -- just make sure you use it carefully.
Arg, I use a laptop... I havent heard of most of those functions, so I have some learning to do tonight. Thanks for the heads up on QueryPerfromanceFrequency() and QueryPerformanceCounter().