示例#1
0
文件: ezab.php 项目: chales/ezab
 * @todo allow setting more curl options: PUT, POST, exit on socket receive error
 * @todo verify if we do proper curl error checking for all cases (404 tested)
 * @todo parse more stats from children (same format as ab does), eg. print connect times, nr. of keepalives etc...
 * @todo check if all our calculation methods are the same as used by ab
 * @todo add some nice graph output, as eg. abgraph does
 * @todo !important add named constants for verbosity levels; review what is ouput at each level (currently used: 1 to 4)
 * @todo !important add an option for a custom dir for traces/logfiles
 * @todo !important raise php timeout if run() is called not from cli
 * @todo !important in web mode, display a form to be filled by user that triggers the request
 */
if (!defined('EZAB_AS_LIB')) {
    if (!function_exists('curl_init')) {
        echo 'Missing cURL, cannot run';
        exit(1);
    }
    $ab = new eZAB();
    if (php_sapi_name() == 'cli') {
        // parse cli options (die with help msg if needed)
        $ab->parseArgs($argv);
    } else {
        // parse options in array format (die with help msg if needed)
        $ab->parseOpts($_GET);
    }
    // will run in either parent or child mode, depending on parsed options
    $ab->run();
}
class eZAB
{
    static $version = '0.3-dev';
    static $defaults = array('verbosity' => 1, 'children' => 1, 'tries' => 1, 'timeout' => 0, 'auth' => false, 'proxy' => false, 'proxyauth' => false, 'target' => '', 'keepalive' => false, 'head' => false, 'interface' => '', 'respencoding' => false, 'httpversion' => CURL_HTTP_VERSION_NONE, 'cookies' => array(), 'skippercentiles' => false, 'extraheaders' => array(), 'childnr' => false, 'parentid' => false, 'self' => __FILE__, 'php' => 'php', 'outputformat' => 'text', 'haltonerrors' => true, 'command' => 'runparent');
    // config options for this instance
示例#2
0
<?php

/**
* example app using ezab.php
*/
define('EZAB_AS_LIB', true);
include 'ezab.php';
$ab = new eZAB(array('verbosity' => 0, 'target' => 'http://localhost/'));
$results = $ab->run();
echo "Requests per second: " . $results['summary_data']['rps'];