Timing helper for javascript