Stopping the time of an action that takes < a second

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

I think you need help anyway for precission timing. Also, if you do it for debugging purposes, why can’t you use a scripting addition or third-party app? You can use GetMilliSec or Jon’s Commands’ “the ticks”, or a javascript call to Safari, probably some obj-c method via “call method” wrapped in a AS-Studio app, etc.

I use myself Smile’s “chrono” command (as I usually debug scripts in Smile). Some time ago I used allways “the ticks”.

In advance, using the Finder (and usually calling any app) will be much slower than invoking osaxen (well-written osaxen, of course) or the shell.