|
There is basically no difference ...
// DumpStack.cpp: Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#define MAX_NUMBER_OF_DATA 1000
int g_dataArray [MAX_NUMBER_OF_DATA];
void global ()
{
// Testing ...
LARGE_INTEGER c1, c2;
:: QueryPerformanceCounter (&c1);
for (int i = 0; i <MAX_NUMBER_OF_DATA; ++ i)
{
g_dataArray [i] = i;
}
:: QueryPerformanceCounter (&c2);
printf ("### Global performance count:% I64u\n", c2.QuadPart-c1.QuadPart);
}
void stack ()
{
int dataArray [MAX_NUMBER_OF_DATA];
// Testing ...
LARGE_INTEGER c1, c2;
:: QueryPerformanceCounter (&c1);
for (int i = 0; i <MAX_NUMBER_OF_DATA; ++ i)
{
dataArray [i] = i;
}
:: QueryPerformanceCounter (&c2);
printf ("### Stacking performance count:% I64u\n", c2.QuadPart-c1.QuadPart);
}
void dump ()
{
int * pDataArray = new int [MAX_NUMBER_OF_DATA];
// Testing ...
LARGE_INTEGER c1, c2;
:: QueryPerformanceCounter (&c1);
for (int i = 0; i <MAX_NUMBER_OF_DATA; ++ i)
{
pDataArray [i] = i;
}
:: QueryPerformanceCounter (&c2);
printf ("### Dumping performance count:% I64u\n", c2.QuadPart-c1.QuadPart);
delete [] pDataArray;
pDataArray = NULL;
}
int main (int argc, char * argv [])
{
for (int i = 0; i <100; ++ i)
{
printf ("======= No.% d ======\n", i);
global ();
dump ();
stack ();
}
return 0;
} |
|