コード例 #1
0
ファイル: bench.php プロジェクト: tempbottle/augmented_types
/**
 * Hello world
 * @param int $iterations a cool bench function with lots of function calls
 * @return array
 */
function is_true_bench_two_calls($iterations)
{
    $start = microtime(true);
    $a = true;
    for ($i = 0; $i < $iterations; $i++) {
        if (!(true === $a)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new UnexpectedValueException("unacceptable!");
        }
    }
    $end = microtime(true);
    $base_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true);
        Assert::received_value()->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true);
        Assert::received_value()->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    return [$base_time, $assert_time, $assert_time];
}