This falls under the Code puzzles the best. Fastest way to render the numbers 1-million in a web browser. Preferably using PHP, but use what you must. Numbers must be more than one on a line in the web browser and must line wrap (the horizontal scroll bar must not be triggered).
rules:
- use any loop construct that you want
- No horizontal scrolling allowed
- Count 1 - 1,000,000 (commas not needed, overshoot is OK)
- Must be a language that displays results in a browser.
For my timer, I'm using:
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
before the code and
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo ("<br /><br /><b>Total count time:</b> ".$totaltime." seconds");
after the code.
microtime(true)
instead of doing your own math? \$\endgroup\$