Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

clocking a release version

$
0
0

I need to make rough estimates for the time used for some computations and for this purpose I have previously used the clock()  in <time.h> with no problems (VS express 2010). A couple of weeks ago I installed visual VS express 2013 on a new machine and now I have problems clocking release versions with the old solution. Here's a small toy example to illustrate what I mean:

#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <cmath>    

long long F(long long n){
	long long res = 0;
	for (long long i = 1; i < n; i++){ res += (long long) ceil(sqrt((double) i * i + 10000)); }
	return res;
}

int main()
{
	clock_t start, end;
	start = clock();
	long long R = F(1000000000);
	end = clock();
	double diff = (double) end - start;
	printf("%lld %f\n", R, diff / CLOCKS_PER_SEC);
	//std::cout << R << " " << diff / CLOCKS_PER_SEC << std::endl;
	return 0;

If I debug this code then there is no problem, I get a timing that seems resonable. However when I swap to a relese version the timing is zero. The release version is faster but not that fast. I tried to use std::cout instead but I still get the timing to zero, but (and this is really strange to me) if I use both output methods at the same time then I get the timing printed correctly (twice).

Robert






Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>