Shamil Salakhetdinov
shamil at users.mns.ru
Mon Oct 31 13:31:40 CST 2005
> Very nice! I'm looking forward ... Here it's Gustav - final results: VB6: 400,000,000 cycles in ~20 seconds C++: 10,000,000,000 cycles in ~18-19 seconds All the source code and test executables can be downloaded from: http://smsconsulting.spb.ru/download/tests/arrayTest.zip (61KB) That was a quick test work but one can find some VB6 advanced coding with Implements, which shows (IMHO) why low coupling and high cohesion is a good and very practically oriented idea (especially for long run projects). Of course there is there also a direct coding - advanced a la' OOP was added to start it getting generalized for someone else to maybe add other languages test cases - anybody? Do not forget to register ATL/COM DLL(ArrayCruncher.dll) before running the test client (ArrayCruncherClient.exe). To register ArrayCruncher.dll run enclosed batch file regme.bat Enjoy! Shamil P.S. C++ core code: #include "stdafx.h" #include "comdef.h" #include <stdio.h> #include "Test.h" #include ".\test.h" #include <time.h> //typedef long COUNTER_TYPE; typedef __int64 COUNTER_TYPE; // LONG vlngCallBackEventInterval, // CTest STDMETHODIMP CTest::ArrayTimeLocal( LONG vlngSequences, LONG vlngLoopMax, BSTR* rstrTotalCnt, LONG* lngSeconds) { const long lngItems = 100; long alngTmp[lngItems][2]; long lngLoop; long lngItem; long lngResult = 0; time_t /*double*/ dblStart; time_t /*double*/ dblStop; COUNTER_TYPE lngCnt; lngCnt=0; time(&dblStart); for (long lngSeqIdx=0; lngSeqIdx < vlngSequences; lngSeqIdx++) { for (lngLoop=0; lngLoop < vlngLoopMax; lngLoop++) { for (lngItem=0; lngItem < lngItems; lngItem++) { alngTmp[lngItem][0] = lngLoop * 10; if (alngTmp[lngItem][0] / 10 == 100) lngResult = 1; else lngResult = 0; lngCnt++; } } } time(&dblStop); *lngSeconds = (long)difftime(dblStop,dblStart);; if(rstrTotalCnt == NULL) return E_POINTER; TCHAR buf[256]; sprintf(buf,"%I64d",lngCnt); Lock(); *rstrTotalCnt = (_bstr_t(buf)).copy(); Unlock(); return S_OK; } ----- Original Message ----- From: "Gustav Brock" <Gustav at cactus.dk> To: <accessd at databaseadvisors.com> Sent: Monday, October 31, 2005 5:08 PM Subject: Re: [AccessD] Array faster in DLL? > Hi Shamil > > Very nice! I'm looking forward ... > > /gustav > > >>> shamil at users.mns.ru 31-10-2005 14:58:24 >>> > <<< > static long ArrayTimeLocal(long lngSequences, long lngLoopMax, long& > lngTotalCnt, bool useTracePrinting = false); > >>> > OK, I will do it this evening after a break I plan for now and I will change > lngTotalCnt to string (strTotalCnt) to pass it back to VBA/VB6 because they > do not have __int64 support. - so the call interface for VBA/VB6 will be: > > function ArrayTimeLocal( _ > byval vlngSequences as long, _ > byval vlngLoopMax as long, _ > byref rstrTotalCnt as string) _ > as Long > > Shamil > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com