Created
January 24, 2014 07:24
-
-
Save juriansluiman/8593421 to your computer and use it in GitHub Desktop.
Benchmarks ran for comparing Beanstalkd and Gearman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'vendor/autoload.php'; | |
$pheanstalk = new Pheanstalk_Pheanstalk('127.0.0.1'); | |
$pheanstalk->useTube('default'); | |
$n = 1000000; | |
$start = microtime(true); | |
for ($i = 0; $i <= $n; $i++) { | |
$job = $pheanstalk->reserve(); | |
} | |
$end = microtime(true); | |
$time = ($end - $start); | |
$ops = $n / $time; | |
echo sprintf("%d operations in %.2f seconds\n", $n, $time); | |
echo sprintf("Meaning %d ops per second\n", $ops); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'vendor/autoload.php'; | |
$pheanstalk = new Pheanstalk_Pheanstalk('127.0.0.1'); | |
$pheanstalk->useTube('default'); | |
$n = 1000000; | |
$start = microtime(true); | |
for ($i = 0; $i <= $n; $i++) { | |
$pheanstalk->put('Foo Bar Baz'); | |
} | |
$end = microtime(true); | |
$time = ($end - $start); | |
$ops = $n / $time; | |
echo sprintf("%d operations in %.2f seconds\n", $n, $time); | |
echo sprintf("Meaning %d ops per second\n", $ops); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'vendor/autoload.php'; | |
$worker = new GearmanWorker; | |
$worker->addServer(); | |
$worker->addFunction('test', function($job) {}); | |
$n = 1000000; | |
$start = microtime(true); | |
for ($i=0; $i <= $n; $i++) { | |
$worker->work(); | |
} | |
$end = microtime(true); | |
$time = ($end - $start); | |
$ops = $n / $time; | |
echo sprintf("%d operations in %.2f seconds\n", $n, $time); | |
echo sprintf("Meaning %d ops per second\n", $ops); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'vendor/autoload.php'; | |
$client = new GearmanClient; | |
$client->addServer(); | |
$n = 1000000; | |
$start = microtime(true); | |
for ($i = 0; $i <= $n; $i++) { | |
$client->doBackground('test', 'This is a test'); | |
} | |
$end = microtime(true); | |
$time = ($end - $start); | |
$ops = $n / $time; | |
echo sprintf("%d operations in %.2f seconds\n", $n, $time); | |
echo sprintf("Meaning %d ops per second\n", $ops); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment