Gustav Brock
Gustav at cactus.dk
Mon Oct 31 05:56:30 CST 2005
Hi Shamil
Oh my ... could you create a DLL with the essentials from your ArrayTimeLocal skipping the console parts? It just need to return the lngSeconds.
Looks like I need some C++ stuff for this project!
/gustav
>>> shamil at users.mns.ru 31-10-2005 12:17:09 >>>
Gustav,
And finally here is managed C++, which runs instantaneously:
#include "stdafx.h"
#using <mscorlib.dll>
#using <Microsoft.VisualBasic.dll>
using namespace System;
static long ArrayTimeLocal(long lngLoopMax, long& lngTotalCnt);
int _tmain()
{
long lngTotalCnt = 0;
long lngResult = 0;
lngResult = ArrayTimeLocal(1000000, lngTotalCnt);
Console::WriteLine(String::Format(
S"Final Result = {0:#,##0}, Final Counter = {1:#,##0}",
__box(lngResult), __box(lngTotalCnt)));
}
static long ArrayTimeLocal(long lngLoopMax, long& lngTotalCnt) {
const long lngItems = 100;
long alngTmp[lngItems-1][2];
long lngLoop;
long lngItem;
long lngResult=0;
double dblStart;
double dblStop;
long lngSeconds;
Console::WriteLine("Array looping test started...");
dblStart = Microsoft::VisualBasic::DateAndTime::Timer;
lngTotalCnt = 0;
for (lngLoop=0; lngLoop < lngLoopMax; lngLoop++) {
for (lngItem=0; lngItem < lngItems; lngItem++) {
alngTmp[lngItem][0] = lngLoop * 10;
if (alngTmp[lngItem][0] / 10 == 100) lngResult = 1;
else lngResult = 0;
lngTotalCnt++;
}
}
dblStop = Microsoft::VisualBasic::DateAndTime::Timer;
Console::WriteLine("Array looping test ended.");
lngSeconds = (long)(dblStop - dblStart);
return lngSeconds;
}
Output
---------
Array looping test started...
Array looping test ended.
Final Result = 0, Final Counter = 100,000,000
And it takes ~18 seconds on my PC to run this test ADDITIONALLY looped 100
times....
Shamil