Is there a way to get the time of an action that takes < a second?
Let’s say I would like to know whether this way of listing a folder
tell application "Finder" to get name of every item of (folder (path to library folder))
is faster than this
list folder (path to library folder) without invisibles
Both routines take less than a second tu run!
If I say:
set startdate to current date
tell application "Finder" to get name of every item of (folder (path to library folder))
set thetime to ((current date) - startdate)
it will return 0 seconds! No chance to get a more precise value?
I know there is an osax called GetMilliSec which can do that.
I’m just wondering whether there is a way to get the time in milliseconds without an osax?
Using a “do shell script” handler that returnes a value in milliseconds?!
I’m not really familiar with the Terminal “man”.
Else you could use this (although it’s just a very rough work-around):
set timescomparison to {}
set n to 100
set startdate to current date
repeat n times
list folder (path to library folder) without invisibles
end repeat
set thetime to ((current date) - startdate) / n
set end of timescomparison to thetime
set startdate to current date
repeat n times
tell application "Finder" to get name of every item of (folder (path to library folder))
end repeat
set thetime to ((current date) - startdate) / n
set end of timescomparison to thetime
--will return a more or less precise value (< 1 second but not 0)
--the greater n is the more precise the result will be
timescomparison