Original Post
What I'm trying to do may well be impossible but I'm interested now.
I'm trying to write a small function that will test the speed of a function that is passed to it.
In order to make this worthwhile it need to be as generic as possible. For this reason I'd like a way of passing a pointer to a function execution if that makes sense. So if I had
function( variable1, variable2);
normally returning something I want to pass a pointer to this execution. Something like this.
template
void test(*func(), int i_max)
{
clock_t begin = clock();
for (int i = 0; i<= i_max; ++i)
{
T temp = *funct;
}
clock_t end = clock();
cout<< "Iterations: "<< i_max <<" Time: "<<(end - begin) < }
Then to use you would call:
test(&function, 100000);
Apologies if this is a stupid question but I feel there out to be some clever method to do this.
I'm trying to write a small function that will test the speed of a function that is passed to it.
In order to make this worthwhile it need to be as generic as possible. For this reason I'd like a way of passing a pointer to a function execution if that makes sense. So if I had
function( variable1, variable2);
normally returning something I want to pass a pointer to this execution. Something like this.
template
void test(*func(), int i_max)
{
clock_t begin = clock();
for (int i = 0; i<= i_max; ++i)
{
T temp = *funct;
}
clock_t end = clock();
cout<< "Iterations: "<< i_max <<" Time: "<<(end - begin) <
Then to use you would call:
test(&function, 100000);
Apologies if this is a stupid question but I feel there out to be some clever method to do this.