Dave's Brain

Browse - programming tips - javascript time the duration of something

Date: 2009dec21
Language: javaScript

Q.  What a compact way to time the duration of something in javaScript?

A.  Herr's an example:

	// Returns milliseconds since 1970
	function getTime() {
        	return (new Date).getTime();
	}

	function exampleUse() {
		var	start;

		start = getTime();

		// do something

		duration = getTime() - start;
	}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.