Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to calculate elapsed time in JavaScript

1 Answer

0 votes
<script type="text/JavaScript">   

var start = new Date();

var sum = 0;
for (var i = 0; i < 10000000; i++)   
    sum += i;

var end = new Date();
var elapsed = end.getTime() - start.getTime(); // elapsed time in milliseconds

document.write("sum = " + sum + " elapsed = " + elapsed);


/*
run:

sum = 49999995000000 elapsed = 26  

*/

</script>

 



answered May 31, 2016 by avibootz

Related questions

1 answer 147 views
147 views asked Dec 22, 2018 by avibootz
1 answer 75 views
75 views asked Oct 17, 2024 by avibootz
1 answer 92 views
92 views asked Aug 4, 2024 by avibootz
1 answer 89 views
89 views asked Aug 4, 2024 by avibootz
1 answer 138 views
2 answers 164 views
164 views asked Oct 14, 2023 by avibootz
...