Lots of changes, implemented the base usage. Beware of bugs and unfinished states
This commit is contained in:
parent
0c23fdfac2
commit
f20551857b
27 changed files with 3045 additions and 71 deletions
29
tests/adaptive_sleep.php
Normal file
29
tests/adaptive_sleep.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use TamerLib\Classes\AdaptiveSleep;
|
||||
|
||||
require 'ncc';
|
||||
import('net.nosial.tamerlib');
|
||||
|
||||
$adaptive_sleep = new AdaptiveSleep(10);
|
||||
|
||||
$time = time();
|
||||
while(true)
|
||||
{
|
||||
if(time() - $time > 3)
|
||||
{
|
||||
// Simulate traffic every 3 seconds
|
||||
$sleep = $adaptive_sleep->sleep(random_int(0, 100) < 90);
|
||||
|
||||
if(time() - $time > 5)
|
||||
{
|
||||
// Stop the simulation after 5 seconds
|
||||
$time = time();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No traffic
|
||||
$sleep = $adaptive_sleep->sleep(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue