*/ 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 protected $opts = array(); function __construct($opts = array()) { $this->opts = self::$defaults; $this->opts['outputformat'] = php_sapi_name() == 'cli' ? 'text' : 'html'; $this->opts['haltonerrors'] = !defined('EZAB_AS_LIB'); $this->opts = array_merge($this->opts, $opts); } /**
<?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'];