コード例 #1
0
function _throttle($function, $wait)
{
    return Underscore::throttle($function, $wait);
}
コード例 #2
0
ファイル: Underscore.php プロジェクト: brombal/underscore.php
 /**
  * @tags functions
  */
 public function testThrottle()
 {
     // it should return a throttled version of the function
     $count = 0;
     $fn = _::throttle(function () use(&$count) {
         $count++;
     }, 10);
     // once every 10ms
     $start = microtime(true);
     do {
         $fn();
     } while ((microtime(true) - $start) * 1000 < 100);
     // 100ms
     $this->integer($count)->isGreaterThan(0)->isLessThanOrEqualTo(10);
 }