diff --git a/base/PerfOptions.php b/base/PerfOptions.php index 59b1dae..bf22796 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -104,6 +104,10 @@ final class PerfOptions { public string $tempDir; public ?string $srcDir; + public ?string $scriptBeforeWarmup; + public ?string $scriptAfterWarmup; + public ?string $scriptAfterBenchmark; + public bool $notBenchmarking = false; private array $args; @@ -156,6 +160,9 @@ public function __construct(Vector $argv) { 'max-delay-admin-request:', 'max-delay-nginx-keepalive:', 'max-delay-nginx-fastcgi:', + 'exec-before-warmup:', + 'exec-after-warmup:', + 'exec-after-benchmark:', 'daemon-files', // daemon output goes to files in the temp directory 'temp-dir:', // temp directory to use; if absent one in /tmp is made 'src-dir:', // location for source to copy into tmp dir instead of ZIP @@ -235,6 +242,10 @@ public function __construct(Vector $argv) { $this->allVolatile = $this->getBool('all-volatile'); $this->interpPseudomains = $this->getBool('interp-pseudomains'); + $this->scriptBeforeWarmup = $this->getNullableString('exec-before-warmup'); + $this->scriptAfterWarmup = $this->getNullableString('exec-after-warmup'); + $this->scriptAfterBenchmark = $this->getNullableString('exec-after-benchmark'); + if ($this->getBool('tcprint')) { $tcprint = hphp_array_idx($o, 'tcprint', null); if (is_string($tcprint) && $tcprint !== '') { diff --git a/base/PerfRunner.php b/base/PerfRunner.php index a65cb42..8b36580 100644 --- a/base/PerfRunner.php +++ b/base/PerfRunner.php @@ -99,6 +99,11 @@ private static function RunWithOptionsAndEngine( $target->sanityCheck(); } + if ($options->scriptBeforeWarmup !== null) { + self::PrintProgress('Starting execution of command: '.$options->scriptBeforeWarmup); + exec($options->scriptBeforeWarmup); + } + if (!$options->skipWarmUp) { self::PrintProgress('Starting Siege for single request warmup'); $siege = new Siege($options, $target, RequestModes::WARMUP); @@ -139,12 +144,22 @@ private static function RunWithOptionsAndEngine( fread(STDIN, 1); } + if ($options->scriptAfterWarmup !== null) { + self::PrintProgress('Starting execution of command: '.$options->scriptAfterWarmup); + exec($options->scriptAfterWarmup); + } + self::PrintProgress('Starting Siege for benchmark'); $siege = new Siege($options, $target, RequestModes::BENCHMARK); $siege->start(); invariant($siege->isRunning(), 'Siege failed to start'); $siege->wait(); + if ($options->scriptAfterBenchmark !== null) { + self::PrintProgress('Starting execution of command: '.$options->scriptAfterBenchmark); + exec($options->scriptAfterBenchmark); + } + self::PrintProgress('Collecting results'); $combined_stats = Map {};