diff --git a/base/PerfOptions.php b/base/PerfOptions.php index 3e3b138..51024e9 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -21,6 +21,13 @@ final class PerfOptions { public ?string $php5; public ?string $hhvm; + // + // setUpTest and tearDownTest are called before and after each + // individual invocation of the $php5 or $hhvm + // + public ?string $setUpTest; + public ?string $tearDownTest; + public array $hhvmExtraArguments; public array $phpExtraArguments; @@ -124,6 +131,9 @@ public function __construct(Vector $argv) { 'dump-pcre-cache', 'profBC', + 'setUpTest:', + 'tearDownTest:', + 'i-am-not-benchmarking', 'hhvm-extra-arguments:', @@ -177,6 +187,9 @@ public function __construct(Vector $argv) { $this->php5 = hphp_array_idx($o, 'php5', null); $this->hhvm = hphp_array_idx($o, 'hhvm', null); + $this->setUpTest = hphp_array_idx($o, 'setUpTest', null); + $this->tearDownTest = hphp_array_idx($o, 'tearDownTest', null); + $this->siege = hphp_array_idx($o, 'siege', 'siege'); $this->nginx = hphp_array_idx($o, 'nginx', 'nginx'); diff --git a/base/PerfRunner.php b/base/PerfRunner.php index f0a8610..87087b7 100644 --- a/base/PerfRunner.php +++ b/base/PerfRunner.php @@ -58,6 +58,18 @@ private static function RunWithOptionsAndEngine( $target->install(); + if ($options->setUpTest != null) { + $command = "OSS_PERF_PHASE=" . "setUp" + . " " . "OSS_PERF_TARGET=" . (string) $target + . " " . $options->setUpTest + ; + self::PrintProgress('Starting setUpTest ' . $command); + shell_exec($command); + self::PrintProgress('Finished setUpTest ' . $command); + } else { + self::PrintProgress('There is no setUpTest'); + } + self::PrintProgress('Starting Nginx'); $nginx = new NginxDaemon($options, $target); $nginx->start(); @@ -149,6 +161,18 @@ private static function RunWithOptionsAndEngine( } $php_engine->stop(); + if ($options->tearDownTest != null) { + $command = "OSS_PERF_PHASE=" . "tearDown" + . " " . "OSS_PERF_TARGET=" . (string) $target + . " " . $options->tearDownTest + ; + self::PrintProgress('Starting tearDownTest ' . $command); + shell_exec($command); + self::PrintProgress('Finished tearDownTest ' . $command); + } else { + self::PrintProgress('There is no tearDownTest'); + } + return $combined_stats; } diff --git a/batch-run.php b/batch-run.php index 2b30ed3..73fdfc3 100644 --- a/batch-run.php +++ b/batch-run.php @@ -19,6 +19,8 @@ enum BatchRuntimeType: string { 'type' => BatchRuntimeType, 'bin' => string, 'args' => Vector, + 'setUpTest' => string, + 'tearDownTest' => string, ); type BatchTarget = shape( @@ -31,6 +33,10 @@ function batch_get_runtime(string $name, array $data): BatchRuntime { 'name' => $name, 'type' => $data['type'], 'bin' => $data['bin'], + 'setUpTest' => array_key_exists('setUpTest', $data) + ? $data['setUpTest'] : null, + 'tearDownTest' => array_key_exists('tearDownTest', $data) + ? $data['tearDownTest'] : null, 'args' => array_key_exists('args', $data) ? new Vector($data['args']) : Vector { }, @@ -135,6 +141,10 @@ function batch_get_single_run( $options->php5 = $runtime['bin']; break; } + + $options->setUpTest = $runtime['setUpTest']; + $options->tearDownTest = $runtime['tearDownTest']; + $options->validate(); return $options;