Skip to content

Instantly share code, notes, and snippets.

@zancarius
Created January 22, 2014 20:34
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 zancarius/4bf09cb24f9ce4d6934a to your computer and use it in GitHub Desktop.
Save zancarius/4bf09cb24f9ce4d6934a to your computer and use it in GitHub Desktop.
This gist is a companion to my "Lies, Damn Lies, and PHP Benchmarks" and is the source of some of the benchmarks used.
<?php
abstract class AbstractOutput
{
abstract public function output ();
}
class Outputter extends AbstractOutput
{
public function output ()
{
return 'Hello, world!';
}
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php $output = new Outputter; echo $output->output(); ?></p>
</body>
</html>
<?php
interface OutputInterface
{
public function output ();
}
abstract class AbstractOutput implements OutputInterface
{
public function output ()
{
return 'Hello, world!';
}
}
class Outputter extends AbstractOutput
{
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php $output = new Outputter; echo $output->output(); ?></p>
</body>
</html>
<?php
interface OutputInterface
{
public function output ();
}
class Output implements OutputInterface
{
public function output ()
{
return 'Hello, world!';
}
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php $output = new Output; echo $output->output(); ?></p>
</body>
</html>
<?php
class Outputter
{
public static function output ()
{
return 'Hello, world!';
}
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php echo Outputter::output(); ?></p>
</body>
</html>
<?php
class Outputter
{
public function output ()
{
return 'Hello, world!';
}
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php $output = new Outputter; echo $output->output(); ?></p>
</body>
</html>
<?php
function output ()
{
return 'Hello, world!';
}
?><!doctype html>
<html>
<head>
<title>PHP Bench</title>
</head>
<body>
<p><?php echo output(); ?></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment