#include <ctime>
#include <iostream>
#include <stdlib.h>     /* srand, rand */

using namespace std;

class C{
    public: int data=0;
};
class B{
    public: C* c;	int accu=0;
    public: B(){
    	c=new C();
    }
    public: void doSomething(){
    	accu+=c->data; //do something about c
    }
};
int main() {
	using namespace std;

	const int NUM=1000000;
	B* bs[NUM];
	for(int n=0;n<NUM;n++){
	    bs[n]=new B();
	}
	for(int loop=0;loop<20;loop++){
		double accumulator=0;
		
		for(int n=0;n<NUM;n++){
			int iSecret = rand() % NUM;
			clock_t begin = clock();
		    bs[iSecret]->doSomething();
		    clock_t end = clock();
		    accumulator+=double(end - begin);
		}
		
		double elapsed_secs = accumulator;
		std::cout<<elapsed_secs<<std::endl;
	}
}