All pastes #185847 Raw Edit

Stuff

public text v1 · immutable
#185847 ·published 2006-09-29 10:54 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>

typedef unsigned char uint8;

int main() {
        int i,j;
        uint8 ***huge_array;
        huge_array = malloc(sizeof(uint8 **) * 1000);
        for(i = 0; i < 1000; i++) {
          huge_array[i] = malloc(sizeof(uint8 *) * 1000);
          for(j = 0; j < 1000; j++) {
            huge_array[i][j] = malloc(sizeof(uint8) * 1000);
          }
        }
        huge_array[999][999][999] = 10;
        printf("%d\n",huge_array[999][999][999]);
        return 0;
}


#include <vector>
#include <iostream>

using namespace std;

int main() {
        vector<vector<vector<unsigned char > > > huge_array(1000, vector<vector<unsigned char > >(1000, vector<unsigned char>(1000,0)));
        huge_array[999][999][999] = 10;
        cout << (int)(huge_array[999][999][999]) << endl;
        return 0;
}

C2D iMac:
$ time ./c-style 
10

real    0m0.092s
user    0m0.047s
sys     0m0.028s
$ time ./stl-style 
10

real    0m8.051s
user    0m5.973s
sys     0m1.806s

Dual Opteron 248 running Linux:
$ time ./c-style 
10

real    0m1.209s
user    0m0.132s
sys     0m1.080s
$ time ./stl-style 
10

real    0m2.248s
user    0m1.244s
sys     0m0.984s