Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Fine tunning siege benchmark options #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions base/PerfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ final class PerfOptions {
public ?string $scriptAfterWarmup;
public ?string $scriptAfterBenchmark;


// Fine tune for some benchmark options.
public ?int $benchmarkConcurrency;
public ?string $benchmarkTime;
public ?int $benchmarkWarmConcurrency;

public bool $notBenchmarking = false;

private array $args;
Expand Down Expand Up @@ -142,6 +148,9 @@ public function __construct(Vector<string> $argv) {
'profBC',
'setUpTest:',
'tearDownTest:',
'benchmark-time:',
'benchmark-concurrency:',
'benchmark-warm-concurrency:',
'i-am-not-benchmarking',
'hhvm-extra-arguments:',
'php-extra-arguments:',
Expand Down Expand Up @@ -215,6 +224,11 @@ public function __construct(Vector<string> $argv) {
$this->forceInnodb = true;
}

$this->benchmarkTime = hphp_array_idx($o, 'benchmark-time', null);
$this->benchmarkConcurrency = hphp_array_idx($o, 'benchmark-concurrency',
null);
$this->benchmarkWarmConcurrency = hphp_array_idx($o,
'benchmark-warm-concurrency', null);
$this->notBenchmarking = array_key_exists('i-am-not-benchmarking', $o);

// If any arguments below here are given, then the "standard
Expand Down Expand Up @@ -376,6 +390,37 @@ public function validate() {
);
}

if ($this->benchmarkTime != null) {
// [1-9]+[HMS]
if (!preg_match("/^[1-9][0-9]*[HMS]{1}$/", $this->benchmarkTime)) {
fprintf(STDERR, "*** WARNING ***\n Invalid benchmark time format: %s.
Examples of valid format are 2M, 30S, 1H. Using default 1M.\n",
$this->benchmarkTime);
// Already have a static method who return the default value for siege.
$this->benchmarkTime = null;
}
}

if ($this->benchmarkWarmConcurrency != null) {
if (!preg_match("/^[1-9][0-9]*/", $this->benchmarkWarmConcurrency)) {
fprintf(STDERR, "*** WARNING ***\n Invalid benchmark concurrency warmup
value: %s. Must be a value greater than 0. Using default 200.\n",
$this->benchmarkWarmConcurrency);
// Already have a static method who return the default value for siege.
$this->benchmarkWarmConcurrency = null;
}
}

if ($this->benchmarkConcurrency != null) {
if (!preg_match("/^[1-9][0-9]*/", $this->benchmarkConcurrency)) {
fprintf(STDERR, "*** WARNING ***\n Invalid benchmark concurrency value:
%s. Must be a value greater than 0. Using default 200.\n",
$this->benchmarkConcurrency);
// Already have a static method who return the default value for siege.
$this->benchmarkConcurrency = null;
}
}

SystemChecks::CheckAll($this);

// Validates that one was defined
Expand Down
20 changes: 17 additions & 3 deletions base/Siege.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,15 @@ protected function getArguments(): Vector<string> {
);
return $arguments;
case RequestModes::WARMUP_MULTI:
if ($this->options->benchmarkWarmConcurrency != null) {
$concurrency = $this->options->benchmarkWarmConcurrency;
} else {
$concurrency = (string) PerfSettings::BenchmarkConcurrency();
}
$arguments->addAll(
Vector {
'-c',
(string) PerfSettings::BenchmarkConcurrency(),
$concurrency,
'-t',
'1M',
'-f',
Expand All @@ -128,10 +133,15 @@ protected function getArguments(): Vector<string> {
);
return $arguments;
case RequestModes::BENCHMARK:
if ($this->options->benchmarkConcurrency != null) {
$concurrency = $this->options->benchmarkConcurrency;
} else {
$concurrency = (string) PerfSettings::BenchmarkConcurrency();
}
$arguments->addAll(
Vector {
'-c',
(string) PerfSettings::BenchmarkConcurrency(),
$concurrency,
'-f',
$urls_file,
'--benchmark',
Expand All @@ -141,7 +151,11 @@ protected function getArguments(): Vector<string> {

if (!$this->options->noTimeLimit) {
$arguments->add('-t');
$arguments->add(PerfSettings::BenchmarkTime());
if ($this->options->benchmarkTime == null) {
$arguments->add(PerfSettings::BenchmarkTime());
} else {
$arguments->add($this->options->benchmarkTime);
}
}
return $arguments;
default:
Expand Down