 void measureProductMatrixVector(Vector(*func)(const Matrix &, const Vector &)) {
 	std::cout << "NEW MEASUREMENTS for Matrix-Vector product: " << std::endl;
 	
-	unsigned long int LAST_NUM_TESTS(MINI_NUM_TESTS);
 	for (unsigned int size(2) ; size < 10000 ; size <<= 1) {
 		Matrix h_m(size, size, CPU);
 		randMatrix(h_m);
 		
 		Vector h_v(size, CPU);
 		randVector(h_v);
-		
-		double time_required(0);
-		unsigned long int NUM_TESTS(LAST_NUM_TESTS >> 2);
-		if (NUM_TESTS < MINI_NUM_TESTS)
-			NUM_TESTS = MINI_NUM_TESTS;
-		
-		while (time_required < 1000.) {
-			clock_t t_chrono;
-			t_chrono = clock();
-			for (unsigned long int i(0) ; i != NUM_TESTS ; i++) {
-				try {		
-					func(h_m, h_v);
-				} catch(cudaError_t &e) {
-					return;
-				}
+			
+		float time_required(0);
+		
+		for (unsigned long int i(0) ; i != NUM_TESTS ; i++) {
+			float time(0);
+			cudaEvent_t start, stop;
+			cudaEventCreate(&start);
+			cudaEventCreate(&stop);
+			cudaEventRecord(start, 0);
+			try {		
+				func(h_m, h_v);
+			} catch(cudaError_t &e) {
+				return;
 			}
-			t_chrono = clock() - t_chrono;
-			time_required = 1000. * ((double) t_chrono)/CLOCKS_PER_SEC;
-			
-			if (time_required < 1000. && NUM_TESTS < (NUM_TESTS<<1))
-				NUM_TESTS <<= 1;
-			else
-				break;
-		}
+			cudaEventRecord(stop, 0);
+			cudaEventSynchronize(stop);
+			cudaEventElapsedTime(&time, start, stop);
+			time_required += time;
+		}
+		time_required /= NUM_TESTS;
 		std::cout << "Size: " << size << "\tTests: " << NUM_TESTS << "\tTime: " << time_required << "ms" << std::endl;
-		LAST_NUM_TESTS = NUM_TESTS;
 	}
 }
 

	
	checkResultsProductMatrixVector(productMatrixVectorCPU, productMatrixVectorGPU_naive);
	checkResultsProductMatrixVector(productMatrixVectorCPU, productMatrixVectorGPU_shared);
	
	measureProductMatrixVector(productMatrixVectorCPU);
	measureProductMatrixVector(productMatrixVectorGPU_naive);
	measureProductMatrixVector(productMatrixVectorGPU_shared);
	
	return 0;
}

#define CPU 1
#define GPU 0

#define NUM_TESTS 16

#define CHECKBOARD_BLOCK_MAX_WIDTH  1
#define CHECKBOARD_BLOCK_MAX_HEIGHT 256
