From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- utils/load_test_run.php | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 utils/load_test_run.php (limited to 'utils/load_test_run.php') diff --git a/utils/load_test_run.php b/utils/load_test_run.php new file mode 100644 index 0000000..47a1619 --- /dev/null +++ b/utils/load_test_run.php @@ -0,0 +1,107 @@ +r{$i} = {$content}
"; + } + + echo "
"; + + flush(); @ob_flush(); +} + +$time_seconds = microtime(true) - $start; +echo "

All Jobs Complete in {$time_seconds} seconds

"; + + + +// odpre asinhrono povezavo na skripto +function JobStartAsync($url, $conn_timeout=30, $rw_timeout=86400) +{ + $errno = ''; + $errstr = ''; + + $url = parse_url($url); + if ($url['scheme'] != 'http') { + die('Only HTTP request are supported !'); + } + + $host = $url['host']; + $path = $url['path']; + $query = $url['query'] != '' ? "?{$url['query']}" : ""; + + set_time_limit(0); + + $fp = fsockopen($host, 80); + + stream_set_blocking($fp, false); + stream_set_timeout($fp, $rw_timeout); + + fputs($fp, "GET {$path}{$query} HTTP/1.1\r\n"); + fputs($fp, "Host: $host\r\n"); + fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); + fputs($fp, "Connection: close\r\n\r\n"); + + return $fp; +} + +// zaporedoma bere fp in vraca kaj se dogaja: returns false if HTTP disconnect (EOF), or a string (could be empty string) if still connected +function JobPollAsync(&$fp) +{ + if ($fp === false) return false; + + if (feof($fp)) { + fclose($fp); + $fp = false; + return false; + } + + return fread($fp, 10000); +} + +?> \ No newline at end of file -- cgit v1.2.3