All pastes #545648 Raw Edit

Mine

public c v1 · immutable
·published 2007-06-06 20:32 UTC
rendered paste body
#include <stdio.h>#include <windows.h>#define N 100000#define small 16#define medium 256#define large 1024void* p[N*2];int main(int argc, char* argv[]){    HANDLE hh = GetProcessHeap();    DWORD t1 = GetTickCount(), t2;    char buf[256];        for (int i=0; i<N; i++)    {        p[i*2] = HeapAlloc(hh, 0, small);        p[i*2+1] = HeapAlloc(hh, 0, medium);    }    for (int i=0; i<N; i++)    {        HeapFree(hh, 0, p[i*2+1]);    }    for (int i=0; i<N; i++)    {        p[i*2+1] = HeapAlloc(hh, 0, large);    }    for (int i=0; i<N; i++)    {        HeapFree(hh, 0, p[i*2]);        HeapFree(hh, 0, p[i*2+1]);    }    t2 = GetTickCount();    sprintf(buf, "Time: %d", t2-t1);    MessageBox(0,buf,"time",0);}