epoch execution time in c 2b 2b

Solutions on MaxInterview for epoch execution time in c 2b 2b by the best coders in the world

showing results for - "epoch execution time in c 2b 2b"
Jakob
30 Mar 2018
1#include <iostream>
2#include <ctime>
3#include <cmath>
4using namespace std;
5
6int main ()
7{
8	float x,y;
9	clock_t time_req;
10
11	// Using pow function
12	time_req = clock();
13	for(int i=0; i<100000; i++)
14	{
15		y = log(pow(i,5));
16	}
17	time_req = clock() - time_req;
18	cout << "Using pow function, it took " << (float)time_req/CLOCKS_PER_SEC << " seconds" << endl;
19	
20	// Without pow function
21	time_req = clock();
22	for(int i=0; i<100000; i++)
23	{
24		y = log(i*i*i*i*i);
25	}
26	time_req = clock()- time_req;
27	cout << "Without using pow function, it took " << (float)time_req/CLOCKS_PER_SEC << " seconds" << endl;
28
29	return 0;
30}