“Time JS Code” Réponses codées

Exécution du temps JavaScript

var t0 = performance.now();

doSomething();   // <---- The function you're measuring time for 

var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
Tough Turtle

temps de nombre javascript

var start = new Date().getTime();

for (i = 0; i < 50000; ++i) {
// do something
}

var end = new Date().getTime();
var time = end - start;
alert('Execution time: ' + time);
Helpful Hyena

Heure javascript

<html>
   <head>
      <title>JavaScript setHours Method</title>
   </head>
   <body>
      <script>
         var dt = new Date();
         dt.setHours( dt.getHours() + 2 );
         document.write( dt );
      </script>
   </body>
</html>
Disgusted Dotterel

script de temps javascript

var start = new Date();

//do some think that takes a while here

var runTime = new Date() - start;
console.log("Script took:"+runTime+" Milliseconds to run");
Friendly Hawk

Time JS Code

// Start your timer
let time1 = performance.now();
// Perform your Loop
for (let i = 0; i <= 10; i++) {
 	console.log(i); 
}
// End your timer
let time2 = performance.now()
// Log the time it took to complete
console.log(`Your loop took ${time1 - time2} milleseconds`);
Anthony Smith

Réponses similaires à “Time JS Code”

Questions similaires à “Time JS Code”

Plus de réponses similaires à “Time JS Code” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code