Example #1
0
 /**
  * Returns the parameters to pass to ab
  * @param ABenchmark $benchmark the benchmark to run
  * @return string the parameters
  */
 protected function buildAbParameters(ABenchmark $benchmark)
 {
     $params = array();
     $params[] = "-n " . $this->requests;
     // the number of requests to make
     $params[] = "-c " . $this->concurrency;
     // the number of concurrent requests
     // last item, the URL
     $params[] = $benchmark->getUrl();
     return implode(" ", $params);
 }
Example #2
0
 /**
  * @param string $url The URL to benchmark
  * @param string $route The route to benchmark
  * @param string $params The parameters to pass to the route or URL, these can be a comma separated list of attribute:value
  *
  */
 public function actionAdd($url = null, $route = null, $params = null)
 {
     if ($url === null && $route === null) {
         throw new CException("Either a URL or a route is required!");
     }
     $model = new ABenchmark();
     $model->url = $url;
     $model->route = $route;
     if ($route !== null && $params !== null) {
         $model->params = array();
         foreach (explode(",", $params) as $param) {
             $param = explode(":", $param);
             $model->params[$param[0]] = $param[1];
         }
     }
     if ($model->save()) {
         echo "Benchmark Added\n";
     } else {
         echo "Failed to save benchmark\n";
         print_r($model->getErrors());
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return ABenchmark the loaded model
  * @throws CHttpException if the model doesn't exist
  */
 public function loadModel($id)
 {
     $model = ABenchmark::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }