Lots of changes, implemented the base usage. Beware of bugs and unfinished states

This commit is contained in:
Netkas 2023-06-12 21:32:35 -04:00
parent 0c23fdfac2
commit f20551857b
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
27 changed files with 3045 additions and 71 deletions

29
tests/adaptive_sleep.php Normal file
View 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);
}
}