// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <ctime>

using namespace std;

static const int REP = 1000;

typedef char *charptr;

int main()
{
    for(int siz = 100; siz <= 100000; siz *= 10)
    {
        int n = 10000000 / siz;
        clock_t t1 = clock();
        for(int i = 0; i < REP; i++)
        {
            charptr* a = new charptr[n];
            for(int j = 0; j < n; j++)
            {
                a[j] = new char[siz];
            }
            for(int j = 0; j < n; j++)
            {
                delete[] a[j];
            }
            delete[] a;
        }
        clock_t t2 = clock();
        cout << "size=" << siz << " n=" << n << ": " << (t2-t1)/(double)CLOCKS_PER_SEC << " seconds" << endl;
    }
    return 0;
}
