当前位置: 首页>>代码示例>>PHP>>正文


PHP Executor::setRerun方法代码示例

本文整理汇总了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 '';
}));
开发者ID:thebeline,项目名称:php-perfdiff-lib,代码行数:31,代码来源:search_vs_foreach.php

示例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());
开发者ID:thebeline,项目名称:php-perfdiff-lib,代码行数:26,代码来源:index_vs_substr.php

示例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());
开发者ID:thebeline,项目名称:php-perfdiff-lib,代码行数:19,代码来源:range_vs_for.php


注:本文中的Executor::setRerun方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。