Q:

test the speed of inline vs non inline functions

I'm learning that inline functions are faster than non-inline functions if the function is kept small. So I do the test below to compare. 
#include <iostream>
#include <ctime>
using namespace std;

int f(const int& ii){return ii+1;}
inline int g(const int& ii){return ii+1;}

int main(){
    int ii = 0;
    clock_t t;
    t = clock();
    for(int i=0;i<1000000;i++){
        ii = f(ii);
    }
    t = clock()-t;
    cout << "Calling the function f 1000000 times cost "<<t<<
    "clicks, corresponding to " << float(t)/CLOCKS_PER_SEC<<"seconds"<<endl;

    ii = 0;
    t = clock();
    for(int i=0;i<1000000;i++){
        ii = g(ii);
    }
    t = clock()-t;
    cout << "Calling the inline function g 1000000 times cost "<<t<<
    "clicks, corresponding to " << float(t)/CLOCKS_PER_SEC<<"seconds"<<endl;    
}

The results are 
1000000
Calling the function f 1000000 times cost 2911clicks, corresponding to 0.002911seconds
Calling the inline function g 1000000 times cost 3291clicks, corresponding to 0.003291seconds

Add: The example above is doing some trivial things so not a good example. I tested another example which sums squares and use a inline function to do the square. 250 times faster using a inline function.
-Don

A:

With optimization on, neither of these functions should compile to anything (they initialize and modify a function local variable, which can be optimized to a no-op). Without optimization turned on, none of the results are worth anything (if performance mattered, you'd have optimization turned on). I wouldn't try drawing useful conclusions from a test that doesn't actually test anything meaningful.

