ParagonIE_Sodium_Compat::runtime_speed_test() public WP 1.0
Runtime testing method for 32-bit platforms.
Usage: If runtime_speed_test() returns FALSE, then our 32-bit implementation is to slow to use safely without risking timeouts. If this happens, install sodium from PECL to get acceptable performance.
{} Это метод класса: ParagonIE_Sodium_Compat{}
Хуков нет.
Возвращает
true|false
. TRUE if we're fast enough, FALSE is not
Использование
$result = ParagonIE_Sodium_Compat::runtime_speed_test( $iterations, $maxTimeout );
- $iterations(число) (обязательный)
- Number of multiplications to attempt
- $maxTimeout(число) (обязательный)
- Milliseconds
Код ParagonIE_Sodium_Compat::runtime_speed_test() ParagonIE Sodium Compat::runtime speed test WP 5.7
public static function runtime_speed_test($iterations, $maxTimeout)
{
if (self::polyfill_is_fast()) {
return true;
}
/** @var float $end */
$end = 0.0;
/** @var float $start */
$start = microtime(true);
/** @var ParagonIE_Sodium_Core32_Int64 $a */
$a = ParagonIE_Sodium_Core32_Int64::fromInt(random_int(3, 1 << 16));
for ($i = 0; $i < $iterations; ++$i) {
/** @var ParagonIE_Sodium_Core32_Int64 $b */
$b = ParagonIE_Sodium_Core32_Int64::fromInt(random_int(3, 1 << 16));
$a->mulInt64($b);
}
/** @var float $end */
$end = microtime(true);
/** @var int $diff */
$diff = (int) ceil(($end - $start) * 1000);
return $diff < $maxTimeout;
}