Skip to content

Commit 7c49112

Browse files
committed
Merge pull request facebookarchive#69 from andreeaflorescu/master
Parameters for running scripts/commands at specific times.
2 parents e41b960 + 8f0f0b0 commit 7c49112

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

base/PerfOptions.php

+11
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ final class PerfOptions {
104104
public string $tempDir;
105105
public ?string $srcDir;
106106

107+
public ?string $scriptBeforeWarmup;
108+
public ?string $scriptAfterWarmup;
109+
public ?string $scriptAfterBenchmark;
110+
107111
public bool $notBenchmarking = false;
108112

109113
private array $args;
@@ -156,6 +160,9 @@ public function __construct(Vector<string> $argv) {
156160
'max-delay-admin-request:',
157161
'max-delay-nginx-keepalive:',
158162
'max-delay-nginx-fastcgi:',
163+
'exec-before-warmup:',
164+
'exec-after-warmup:',
165+
'exec-after-benchmark:',
159166
'daemon-files', // daemon output goes to files in the temp directory
160167
'temp-dir:', // temp directory to use; if absent one in /tmp is made
161168
'src-dir:', // location for source to copy into tmp dir instead of ZIP
@@ -235,6 +242,10 @@ public function __construct(Vector<string> $argv) {
235242
$this->allVolatile = $this->getBool('all-volatile');
236243
$this->interpPseudomains = $this->getBool('interp-pseudomains');
237244

245+
$this->scriptBeforeWarmup = $this->getNullableString('exec-before-warmup');
246+
$this->scriptAfterWarmup = $this->getNullableString('exec-after-warmup');
247+
$this->scriptAfterBenchmark = $this->getNullableString('exec-after-benchmark');
248+
238249
if ($this->getBool('tcprint')) {
239250
$tcprint = hphp_array_idx($o, 'tcprint', null);
240251
if (is_string($tcprint) && $tcprint !== '') {

base/PerfRunner.php

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ private static function RunWithOptionsAndEngine(
9999
$target->sanityCheck();
100100
}
101101

102+
if ($options->scriptBeforeWarmup !== null) {
103+
self::PrintProgress('Starting execution of command: '.$options->scriptBeforeWarmup);
104+
exec($options->scriptBeforeWarmup);
105+
}
106+
102107
if (!$options->skipWarmUp) {
103108
self::PrintProgress('Starting Siege for single request warmup');
104109
$siege = new Siege($options, $target, RequestModes::WARMUP);
@@ -139,12 +144,22 @@ private static function RunWithOptionsAndEngine(
139144
fread(STDIN, 1);
140145
}
141146

147+
if ($options->scriptAfterWarmup !== null) {
148+
self::PrintProgress('Starting execution of command: '.$options->scriptAfterWarmup);
149+
exec($options->scriptAfterWarmup);
150+
}
151+
142152
self::PrintProgress('Starting Siege for benchmark');
143153
$siege = new Siege($options, $target, RequestModes::BENCHMARK);
144154
$siege->start();
145155
invariant($siege->isRunning(), 'Siege failed to start');
146156
$siege->wait();
147157

158+
if ($options->scriptAfterBenchmark !== null) {
159+
self::PrintProgress('Starting execution of command: '.$options->scriptAfterBenchmark);
160+
exec($options->scriptAfterBenchmark);
161+
}
162+
148163
self::PrintProgress('Collecting results');
149164

150165
$combined_stats = Map {};

0 commit comments

Comments
 (0)