Say I wanted to define a function “start” and a function “stop”, and I wanted to output as accurately as possible the real time between the two functions getting called? The time elapsed will probably be in microseconds.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Create new Date objects at the beginning of each method. Use the
getTime()method to get the milliseconds value for the date. Subtract thestartvalue from theendvalue. That is the difference, in milliseconds.I’m not aware of any general way of getting better than millisecond time resolution in browser side javascript.