mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 00:32:15 +09:00
Add some delays to timer test
This commit is contained in:
parent
509893e791
commit
97c10ab2cf
1 changed files with 9 additions and 1 deletions
|
|
@ -5,9 +5,13 @@ class TimerTest extends \Codeception\TestCase\Test
|
||||||
function testStartStop()
|
function testStartStop()
|
||||||
{
|
{
|
||||||
$t1 = microtime(true);
|
$t1 = microtime(true);
|
||||||
|
usleep(1000);
|
||||||
$started = Rhymix\Framework\Timer::start();
|
$started = Rhymix\Framework\Timer::start();
|
||||||
|
usleep(1000);
|
||||||
$t2 = microtime(true);
|
$t2 = microtime(true);
|
||||||
|
usleep(1000);
|
||||||
$elapsed = Rhymix\Framework\Timer::stop();
|
$elapsed = Rhymix\Framework\Timer::stop();
|
||||||
|
usleep(1000);
|
||||||
$t3 = microtime(true);
|
$t3 = microtime(true);
|
||||||
|
|
||||||
$this->assertGreaterThanOrEqual($t1, $started);
|
$this->assertGreaterThanOrEqual($t1, $started);
|
||||||
|
|
@ -20,8 +24,11 @@ class TimerTest extends \Codeception\TestCase\Test
|
||||||
function testNestedTimers()
|
function testNestedTimers()
|
||||||
{
|
{
|
||||||
$t1 = Rhymix\Framework\Timer::start();
|
$t1 = Rhymix\Framework\Timer::start();
|
||||||
|
usleep(1000);
|
||||||
$t2 = Rhymix\Framework\Timer::start();
|
$t2 = Rhymix\Framework\Timer::start();
|
||||||
|
usleep(1000);
|
||||||
$t3 = Rhymix\Framework\Timer::stop();
|
$t3 = Rhymix\Framework\Timer::stop();
|
||||||
|
usleep(1000);
|
||||||
$t4 = Rhymix\Framework\Timer::stop();
|
$t4 = Rhymix\Framework\Timer::stop();
|
||||||
|
|
||||||
$this->assertGreaterThanOrEqual($t1, $t2);
|
$this->assertGreaterThanOrEqual($t1, $t2);
|
||||||
|
|
@ -33,7 +40,7 @@ class TimerTest extends \Codeception\TestCase\Test
|
||||||
$t1 = Rhymix\Framework\Timer::start('timer1');
|
$t1 = Rhymix\Framework\Timer::start('timer1');
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
$t2 = Rhymix\Framework\Timer::start('timer2');
|
$t2 = Rhymix\Framework\Timer::start('timer2');
|
||||||
|
usleep(1000);
|
||||||
$t3 = Rhymix\Framework\Timer::stop('timer1');
|
$t3 = Rhymix\Framework\Timer::stop('timer1');
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
$t4 = Rhymix\Framework\Timer::stop('timer2');
|
$t4 = Rhymix\Framework\Timer::stop('timer2');
|
||||||
|
|
@ -45,6 +52,7 @@ class TimerTest extends \Codeception\TestCase\Test
|
||||||
function testTimerFormat()
|
function testTimerFormat()
|
||||||
{
|
{
|
||||||
$t1 = Rhymix\Framework\Timer::start();
|
$t1 = Rhymix\Framework\Timer::start();
|
||||||
|
usleep(1000);
|
||||||
$t2 = Rhymix\Framework\Timer::stopFormat();
|
$t2 = Rhymix\Framework\Timer::stopFormat();
|
||||||
|
|
||||||
$this->assertRegexp('/^[0-9\.,]+ms$/', $t2);
|
$this->assertRegexp('/^[0-9\.,]+ms$/', $t2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue