AndreiL
Welcome to AndreiL.
Enjoy your time.
Please log in.

Timer for functions: C++ example

Go down

Timer for functions: C++ example

Post by Lucaci Andrei on Wed Jun 20, 2012 7:32 pm

Here's a quick example of how you can make a timer for a function in C++:
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <ctime>
#include <iostream>
void timer(void(*f)()){
unsigned int start=clock();
f();
std::cout<<"Time of the execution in seconds: "<<0.001*(clock()-start)<<"\n\n";
}

void print(){
str::cout<<"AAAA\n";
}

int main(){
timer(print);
return (0);
}

avatar
Lucaci Andrei
"Tata Lor"


Number of messages : 222
Points : 2266743
Reputation : 1007
Registration date : 2008-08-15
Age : 26
Location : Cluj-Napoca

View user profile http://www.andreil.wgz.ro

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum