All pastes #838917 Raw Edit

Someone

public text v1 · immutable
#838917 ·published 2007-12-30 19:16 UTC
rendered paste body
// Valami.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
//using namespace std;

#define SIZE 100000
#define REPEAT 1000
#define TOTAL_REP 100
#define TYPE int

#define TEST(x,y) s = clock(); for(int j = 0; j < REPEAT; j++) for(int i = 0; i < SIZE; i++) x[i] = x[0]+x[SIZE-1]+x[i/2]; e[y] += clock() - s;

TYPE *a;
TYPE b[SIZE+1];

void main (void)
{
    a = new TYPE[SIZE+1];
    TYPE *c = new TYPE[SIZE+1];
    TYPE d[SIZE+1] = {};

	clock_t s,e[4] = {0,0,0,0};
	for(int k = 0; k < TOTAL_REP; k++)
	{
		TEST(a,0);
		TEST(b,1);
		TEST(c,2);
		TEST(d,3);
	}

	for(int i = 0; i < 4; i++)
		printf("Time: %f\n", (float)(e[i]) / float(TOTAL_REP) / (float)CLK_TCK);
    getch();
}