Skip to content

Instantly share code, notes, and snippets.

@pborreli
Forked from ckdake/gist:900040
Created April 3, 2011 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pborreli/900098 to your computer and use it in GitHub Desktop.
Save pborreli/900098 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p0 adella:benchmarks$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]
ruby-1.9.2-p0 adella:benchmarks$ php -v
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
ruby-1.9.2-p0 adella:benchmarks$ cat foo.rb
msg = "Hello world"
100000.times do
puts <<EOF
<html><body>#{msg}</body></html>
EOF
end
ruby-1.9.2-p0 adella:benchmarks$ cat foo.php
<?php
$message = "Hello world";
for($i=0;$i<100000;$i++) {
?>
<html><body><?= message ?></body></html>
<?php } ?>
ruby-1.9.2-p0 adella:benchmarks$ cat foo-ng.php
<?php
$message = "Hello world";
for($i=0;$i<100000;$i++) {
print <<<EOF
<html><body>$message</body></html>
EOF;
}
ruby-1.9.2-p0 adella:benchmarks$ time ruby foo.rb >/dev/null
real 0m0.090s
user 0m0.084s
sys 0m0.005s
ruby-1.9.2-p0 adella:benchmarks$ time php foo.php >/dev/null
real 0m0.352s
user 0m0.198s
sys 0m0.150s
ruby-1.9.2-p0 adella:benchmarks$ time php foo-ng.php >/dev/null
real 0m0.132s
user 0m0.073s
sys 0m0.055s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment