本文整理汇总了PHP中Executor::setRerun方法的典型用法代码示例。如果您正苦于以下问题:PHP Executor::setRerun方法的具体用法?PHP Executor::setRerun怎么用?PHP Executor::setRerun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Executor
的用法示例。
在下文中一共展示了Executor::setRerun方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Executor
<?php
namespace BRS\PerformanceDiff;
$executor = new Executor('Testing finding a Key by value using foreach and array_search.', 100, Executor::TARE | Executor::PROGRESS);
$executor->setPrepCallback(function ($executor) {
$executor->setPayload(range(10000, 1000000));
});
$executor->setTareFunction(function ($payload) {
$find = rand(0, 1000000);
return null;
});
$executor->setRerun(1);
$executor->addTest(new Test('Search', function ($payload) {
$find = rand(0, 1000000);
return array_search($find, $payload);
}));
$executor->addTest(new Test('FlipIsSet', function ($payload) {
$find = rand(0, 1000000);
$payload = array_flip($payload);
return isset($payload[$find]) ? $payload[$find] : null;
}));
$executor->addTest(new Test('ForEach', function ($payload) {
$find = rand(0, 1000000);
foreach ($payload as $key => $value) {
if ($value == $find) {
return $key;
}
}
return '';
}));
示例2: Executor
<?php
namespace BRS\PerformanceDiff;
$executor = new Executor('Testing getting a char in a string using indexing vs substrings.', 1000000, Executor::TARE | Executor::PROGRESS);
$executor->setPrepCallback(function ($executor) {
$string = '';
$pool = '1234567890qwertyuiopasdfghjklzxcvbnm';
while (strlen($string) > 10000) {
// hint hint...
$string .= $string[rand(0, strlen($pool) - 1)];
}
$executor->setPayload(array(strlen($string), $string));
});
$executor->setTareFunction(function ($payload) {
return rand(0, $payload[0] - 1);
});
$executor->setRerun(10);
$executor->addTest(new Test('Index', function ($payload) {
return $payload[1][rand(0, $payload[0] - 1)];
}));
$executor->addTest(new Test('Substr', function ($payload) {
return substr($string, rand(0, $payload[0]), 1);
}));
$executor->execute();
$executor->log(basename(__FILE__) . '.' . time());
示例3: Executor
<?php
namespace BRS\PerformanceDiff;
$executor = new Executor('Testing iteration on range() vs for loop.', 100000000, Executor::TARE | Executor::PROGRESS);
$executor->setRerun(5);
$executor->setPayload(4800000);
$executor->addTest(new Test('Range', function ($payload) {
foreach (range(1, $payload) as $i) {
}
return NULL;
}));
$executor->addTest(new Test('For Loop', function ($payload) {
for ($i = 1; $i <= $payload; $i++) {
}
return NULL;
}));
$executor->execute();
$executor->log(basename(__FILE__) . '.' . time());