Article View: borland.public.cppbuilder.nativeapi
Article #6617Weird optimisation results
From: Andrue Cope [TeamB]
Date: Thu, 28 Apr 2005 09:18
Date: Thu, 28 Apr 2005 09:18
44 lines
2305 bytes
2305 bytes
I spent some time yesterday migrating one of our projects to VC.NET
(just out of curiousity). Although not complete it did draw my
attention to a function that looked like it could be improved. The
routine is an old one and obviously dates back to the days of BC45 when
QWORDs weren't around. Or perhaps even BC31.
void NTDate2APC( BYTE *sourceDate,
TAPCDateTime *targetDate )
{
long double bigNumber=*( sourceDate++ );
for( WORD l1=1;
l1<8;
++l1,++sourceDate )
bigNumber+=( pow( 2, ( long double )( ( l1*8 ) ) )*( *sourceDate )
);
long double secondsSince1601=bigNumber/10000000L;
....
It occurred to me that replacing this with
void NTDate2APC( BYTE *sourceDate,
TAPCDateTime *targetDate )
{
QWORD secondsSince1601=
( *reinterpret_cast<QWORD *>( sourceDate ) )/10000000ui64;
would offer a performance improvement.
It doesn't. In fact it gives a performance hit. On my standard NTFS
test image the old code averages 38 seconds over ten runs. The new code
averages 34 seconds over ten runs.
I can appreciate that empirical testing is going to be innaccurate but
the results seem pretty clear cut. I just don't see how the original
code can be faster.
FWIW the test image contains around 7,000 files and each file has four
date/time stamps. The program is only generating a file listing.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<4270aa35$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,558eed2a222ed4da,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address> Subject: Weird optimisation results Newsgroups: borland.public.cppbuilder.nativeapi Date: Thu, 28 Apr 2005 10:18:13 +0100 User-Agent: XanaNews/1.17.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 217.207.223.34 Message-ID: <4270aa35$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1114679861 217.207.223.34 (28 Apr 2005 02:17:41 -0700) Lines: 44 X-Authenticated-User: acope Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail