Re: monthNumber (was: Create a folder with today's date...)
Re: monthNumber (was: Create a folder with today's date...)
- Subject: Re: monthNumber (was: Create a folder with today's date...)
- From: Nigel Garvey <email@hidden>
- Date: Tue, 12 Feb 2002 00:13:02 +0000
has wrote on Mon, 11 Feb 2002 15:06:22 +0000:
>
Here's a fresh comparison, using an if...elseif block as Paul suggested
>
(=30% faster than my previous version).
>
>
======================================================================
>
>
on monthToInteger(theMonth)
>
if theMonth is January then
>
return 1
>
else if theMonth is February then
[etc.]
>
end monthToInteger
>
>
on GetMonthNumber(theDate)
>
copy theDate to b
>
set the month of b to January
>
return 1 + (theDate - b + 1314864) div 2629728
>
end GetMonthNumber
>
>
set r to date "Sunday, December 1, 2002 12:00:00am"
>
>
set a to the ticks
>
repeat 100000 times
>
monthToInteger(r's month)
>
end repeat
>
set b to the ticks
>
repeat 100000 times
>
GetMonthNumber(r)
>
end repeat
>
set c to the ticks
>
{b - a, c - b}
>
>
--> {150, 373} (January)
>
--> {329, 380} (December)
>
>
======================================================================
>
>
Now, it beats FV even in the worst case (December), at least for me. It may
>
be that other folks' mileage varies according to AS version (I'm on 1.3.7 -
>
can't speak for other versions).
On my AS 1.6 machine, the typical results are:
--> {252, 640} (January)
--> {1276, 644} (December)
They break even in May with {649, 643}. (Using Richard Hartman's
optimisation or mine only advantages French Vanilla by about three
ticks.) That makes four months where if/else is faster, one where the two
methods take about the same time, and seven where French Vanilla has a
clear lead.
On my much slower AS 1.3.7 machine however, testing under conditions as
identical as I can make them, the typical December result is {1779,
2210}, which confirms your results for that version of AppleScript. The
if/else test only takes 1.4 times as long on my slower machine; French
Vanilla takes 3.4 times as long. I can't think of any reason why there
should be such a difference. But it may explain why my speed-advantage
results have differed from other people's in the past.
Velly intervestink....
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.