Actually, the code I referenced is appropriate to log the time when a particular event in the script starts and/or finishes. Usually, it's assumed that a timestamp shows the completion of an event, the start time being the completion of the prior event. Of course, you can log the start and end if you want, particularly if you are logging specific function blocks and not every step along the way.

The TimeDiff that Mart pointed you to returns the difference between two timestamps, with ms accurracy. I would not use that for performance logging as there is much more overhead compared to the TimeStamp() UDF. It would be perfect, however, to use to determine precise differences between each of the values written to the perf log, probably by an analysis tool that read the perf log starting at line 2 and compared the time value with the prior line's time value. Something like
$aPerfData = FileIO('.\perflog.log', 'R')
For $P = 1 to UBound($aPerfData)
  $Time1 = Left($aPerfData[$P - 1], 23)  ; prior value
  $Time2 = Left($aPerfData[$P], 23)      ; current value
  $Diff = TimeDiff($Time1, $Time2, , 1)  ; difference w/ MS 
  $aPerfData[$P] = $aPerfData[$P] + ' - ' + $Diff + ' Seconds.'
$ = FileIO('.\perflog.log', 'W', $aPerfData)
This will calculate the difference between entries and write the different back to the file.

Actually I am a Rocket Scientist! \:D