Can I use Javascript to throw the computer a bunch of random mathematical equations, then have it tell me the time taken for the operation?
Will this give a true and accurate representation about the speed of a computer?
I created a sample Javascript code just to document.write numbers up till 50,000.
var start = new Date().getTime();
document.write("<h1>Start</h1><br><h3>Time taken:</h3>");
for (i = 0; i <= 50000; ++i) {
document.write(i+"\n");
}
var end = new Date().getTime();
var time = end - start;
document.write("<h1>Success.</h1>");
alert("For the program to execute, it took this computer... \n\n" + time + " milliseconds.\n\nOperation was SUCCESSFUL. ✓");
Aucun commentaire:
Enregistrer un commentaire