You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
21
vendor/swoole/tests/include/api/swoole_timer/accurate_test.php
vendored
Executable file
21
vendor/swoole/tests/include/api/swoole_timer/accurate_test.php
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/../../../include/bootstrap.php";
|
||||
|
||||
//swoole_function swoole_timer_after($ms, $callback, $param = null) {}
|
||||
//swoole_function swoole_timer_tick($ms, $callback) {}
|
||||
//swoole_function swoole_timer_clear($timer_id) {}
|
||||
|
||||
|
||||
function after()
|
||||
{
|
||||
$start = microtime(true);
|
||||
swoole_timer_after(1000, function() use($start) {
|
||||
echo microtime(true) - $start, "\n";
|
||||
after();
|
||||
});
|
||||
}
|
||||
|
||||
//for ($i = 0; $i < 10000; $i++) {
|
||||
after();
|
||||
//}
|
79
vendor/swoole/tests/include/api/swoole_timer/fixRate_vs_fixDelay.php
vendored
Executable file
79
vendor/swoole/tests/include/api/swoole_timer/fixRate_vs_fixDelay.php
vendored
Executable file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
function fixRate(callable $callable, $interval)
|
||||
{
|
||||
return swoole_timer_tick($interval, $callable);
|
||||
}
|
||||
|
||||
function fixDelay(callable $callable, $interval)
|
||||
{
|
||||
return swoole_timer_after($interval, function() use($callable, $interval) {
|
||||
call_user_func($callable);
|
||||
fixDelay($callable, $interval);
|
||||
});
|
||||
}
|
||||
|
||||
function randBlock()
|
||||
{
|
||||
$n = mt_rand(0, 10);
|
||||
for ($i = 0; $i < 1000000 * $n; $i++) {}
|
||||
}
|
||||
|
||||
/*
|
||||
$t = microtime(true);
|
||||
fixDelay(swoole_function() use(&$t) {
|
||||
echo number_format(microtime(true) - $t, 3), PHP_EOL;
|
||||
randBlock();
|
||||
$t = microtime(true);
|
||||
}, 1000);
|
||||
//*/
|
||||
/*
|
||||
1.007
|
||||
1.005
|
||||
1.005
|
||||
1.004
|
||||
1.003
|
||||
1.004
|
||||
1.002
|
||||
1.006
|
||||
1.006
|
||||
1.005
|
||||
1.004
|
||||
1.002
|
||||
1.006
|
||||
1.004
|
||||
1.002
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
$t = microtime(true);
|
||||
fixRate(swoole_function() use(&$t) {
|
||||
echo number_format(microtime(true) - $t, 3), PHP_EOL;
|
||||
randBlock();
|
||||
$t = microtime(true);
|
||||
}, 1000);
|
||||
*/
|
||||
/*
|
||||
1.003
|
||||
0.759
|
||||
1.005
|
||||
0.538
|
||||
1.002
|
||||
1.003
|
||||
0.763
|
||||
1.005
|
||||
0.247
|
||||
1.004
|
||||
1.004
|
||||
0.270
|
||||
1.005
|
||||
0.199
|
||||
1.000
|
||||
0.335
|
||||
1.005
|
||||
1.006
|
||||
0.239
|
||||
1.004
|
||||
0.119
|
||||
*/
|
26
vendor/swoole/tests/include/api/swoole_timer/invalid_args.php
vendored
Executable file
26
vendor/swoole/tests/include/api/swoole_timer/invalid_args.php
vendored
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/../../../include/bootstrap.php";
|
||||
|
||||
//swoole_function swoole_timer_after($ms, $callback, $param = null) {}
|
||||
//swoole_function swoole_timer_tick($ms, $callback) {}
|
||||
//swoole_function swoole_timer_clear($timer_id) {}
|
||||
|
||||
swoole_timer_after(-1, function(){ });
|
||||
swoole_timer_tick(-1, function() { });
|
||||
swoole_timer_after(86400001, function(){ });
|
||||
swoole_timer_tick(86400001, function() { });
|
||||
swoole_timer_clear(-1);
|
||||
|
||||
for ($i = 0; $i < 1000; $i++) {
|
||||
swoole_timer_clear(swoole_timer_after(1, function() {}));
|
||||
}
|
||||
|
||||
//swoole_timer_after(1, null);
|
||||
//swoole_timer_after(1, "strlen");
|
||||
|
||||
function sw_timer_pass_ref(&$ref_func) {
|
||||
swoole_timer_after(1, $ref_func);
|
||||
}
|
||||
$func = function() {};
|
||||
sw_timer_pass_ref($func);
|
9
vendor/swoole/tests/include/api/swoole_timer/multi_timer.php
vendored
Executable file
9
vendor/swoole/tests/include/api/swoole_timer/multi_timer.php
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/../../../include/bootstrap.php";
|
||||
|
||||
for ($j = 0; $j < 100; $j++) {
|
||||
swoole_timer_after(1, function() use($j){
|
||||
echo $j, "\n";
|
||||
});
|
||||
}
|
86
vendor/swoole/tests/include/api/swoole_timer/register_shutdown_priority.php
vendored
Executable file
86
vendor/swoole/tests/include/api/swoole_timer/register_shutdown_priority.php
vendored
Executable file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
// first shutdown func
|
||||
// timer after
|
||||
function func1()
|
||||
{
|
||||
register_shutdown_function(function() {
|
||||
echo "first shutdown func\n";
|
||||
});
|
||||
|
||||
// $start = microtime(true);
|
||||
swoole_timer_after(1, function() /*use($start)*/ {
|
||||
echo "timer after\n";
|
||||
// echo (microtime(true) - $start) * 1000 - 1;
|
||||
});
|
||||
}
|
||||
|
||||
// first shutdown func
|
||||
// timer after
|
||||
function func1_2()
|
||||
{
|
||||
$order4 = function() { echo "first shutdown func\n"; };
|
||||
$order5 = function() { swoole_event_wait(); };
|
||||
$order6 = function() { echo "timer after\n";};
|
||||
|
||||
// order 1
|
||||
register_shutdown_function($order4);
|
||||
// order 2
|
||||
register_shutdown_function($order5);
|
||||
// order 3
|
||||
swoole_timer_after(1, $order6);
|
||||
}
|
||||
|
||||
|
||||
// timer after
|
||||
// first shutdown func
|
||||
function func2()
|
||||
{
|
||||
register_shutdown_function(function() {
|
||||
echo "first shutdown func\n";
|
||||
});
|
||||
|
||||
swoole_timer_after(1, function() {
|
||||
echo "timer after\n";
|
||||
});
|
||||
|
||||
swoole_event_wait();
|
||||
}
|
||||
|
||||
|
||||
// first shutdown func
|
||||
// timer after
|
||||
// second shutdown func
|
||||
function func3()
|
||||
{
|
||||
register_shutdown_function(function() {
|
||||
echo "first shutdown func\n";
|
||||
});
|
||||
|
||||
swoole_timer_after(1, function() {
|
||||
echo "timer after\n";
|
||||
register_shutdown_function(function() {
|
||||
echo "second shutdown func\n";
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function recv_shutdow()
|
||||
{
|
||||
register_shutdown_function(function() {
|
||||
echo "shutdown\n";
|
||||
recv_shutdow();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//recv_shutdow();
|
||||
//func1();
|
||||
func1_2();
|
||||
//func2();
|
||||
//func3();
|
||||
|
||||
|
Reference in New Issue
Block a user