/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>
Comments
