示例#1
0
文件: run.php 项目: ErosZy/CSF
<?php

$config = [];
require_once "./config.php";
require_once "./Benchmark.php";
$bc = new Benchmark($config["test_function"]);
$bc->process_num = $config["process_num"];
$bc->request_num = $config["request_num"];
$bc->server_url = $config["server_url"];
$bc->server_config = parse_url($config["server_url"]);
$send_data = $config["send_data"];
$package_eof = $config["package_eof"];
$bc->process_req_num = intval($bc->request_num / $bc->process_num);
$bc->run();
$bc->report();
function long_tcp(Benchmark $bc)
{
    global $send_data, $package_eof;
    static $client = null;
    static $i;
    static $index;
    $start = microtime(true);
    if (empty($client)) {
        $client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
        $client->set(array('open_eof_check' => true, "package_eof" => $package_eof));
        $end = microtime(true);
        $conn_use = $end - $start;
        $bc->max_conn_time = $conn_use;
        $i = 0;
        $index = 0;
        if (!$client->connect($bc->server_config['host'], $bc->server_config['port'], 2)) {