Beispiel #1
0
/**
 * @param int $iterations
 * @return array
 */
function run_is_true_with_four_chains($iterations)
{
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true)->is_true(true)->is_true(true)->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        Assert::argument()->is_true(true)->is_true(true)->is_true(true)->is_true(true);
    }
    $end = microtime(true);
    $assert_time = $end - $start;
    $start = microtime(true);
    for ($i = 0; $i < $iterations; $i++) {
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
        if (!(true === true)) {
            throw new InvalidArgumentException("unacceptable!");
        }
    }
    $end = microtime(true);
    $base_time = $end - $start;
    return [$base_time, $assert_time, $assert_time];
}
Beispiel #2
0
 /**
  * @param unknown $object to test
  * @param string $trait_name
  * @return bool
  */
 public static function is_trait_used($object, $trait_name)
 {
     Assert::argument()->is_object($object)->is_string($trait_name)->is_not_empty($trait_name);
     return array_key_exists($trait_name, class_uses($object));
 }