Return to Snippet

Revision: 35637
at November 11, 2010 07:22 by geekyjohn


Initial Code
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		
		var str = document.getElementById('txt').value, 
			n = [],
			startTime = new Date().getTime(),
			endTime = 0,
			totalTime = 0,
			l = 0,
			i = 0;

		/*
		  simple method that iterates over a string and adds
		  each char to an array so see how fast it is.
		*/
		function go() {

			for (i=0,l=str.length; i<l; i++) {
				n.push(str.charAt(i));
			}
		
			endTime = new Date().getTime();
		
		}

		go();

		totalTime = endTime - startTime;
		
		
		$("#time").html("<p>Time: "+totalTime+"ms</p>");
	});
</script>

Initial URL

                                

Initial Description

                                

Initial Title
JS Code Execution Time

Initial Tags
javascript

Initial Language
JavaScript