Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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