From 7e7af29e5816e81fad8ac73eb93c153942862f71 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Thu, 4 Jun 2015 14:38:49 -0700 Subject: [PATCH] hh_format everything --- base/BuildChecker.php | 7 +- base/DatabaseInstaller.php | 64 ++++---- base/HHVMDaemon.php | 173 +++++++++++--------- base/NginxDaemon.php | 30 ++-- base/PHP5Daemon.php | 23 +-- base/PerfOptions.php | 120 ++++++-------- base/PerfRunner.php | 60 ++++--- base/PerfTarget.php | 22 +-- base/Process.php | 23 +-- base/Siege.php | 83 +++++----- base/SiegeStats.php | 10 +- base/SystemChecks.php | 8 +- base/Utils.php | 33 ++-- base/cli-init.php | 7 +- batch-run.php | 57 ++++--- perf.php | 2 +- targets/codeigniter/CodeIgniterTarget.php | 27 ++- targets/drupal7/Drupal7Target.php | 10 +- targets/drupal8/Drupal8Target.php | 33 ++-- targets/laravel4/Laravel4Target.php | 44 ++--- targets/laravel5/Laravel5Target.php | 44 ++--- targets/magento1/Magento1Target.php | 101 ++++++------ targets/mediawiki/MediaWikiTarget.php | 28 ++-- targets/sugarcrm/SugarCRMHomePageTarget.php | 17 +- targets/sugarcrm/SugarCRMTarget.php | 15 +- targets/wordpress/WordpressTarget.php | 52 +++--- 26 files changed, 549 insertions(+), 544 deletions(-) diff --git a/base/BuildChecker.php b/base/BuildChecker.php index 76aec4e..b0bd239 100644 --- a/base/BuildChecker.php +++ b/base/BuildChecker.php @@ -20,7 +20,10 @@ private static function MakeCheckedValue(array $foo): CheckedValue { invariant(array_key_exists('OK', $foo), 'invalid JSON data'); invariant(array_key_exists('Value', $foo), 'invalid JSON data'); invariant(array_key_exists('Required Value', $foo), 'invalid JSON data'); - invariant($foo['OK'] === true || $foo['OK'] === false, 'invalid JSON data'); + invariant( + $foo['OK'] === true || $foo['OK'] === false, + 'invalid JSON data', + ); // UNSAFE return $foo; } @@ -60,7 +63,7 @@ public static function Check( STDERR, "Exiting due to invalid config. You can run anyway with ". "--i-am-not-benchmarking, but the results will not be suitable for ". - "any kind of comparison.\n" + "any kind of comparison.\n", ); exit(1); } diff --git a/base/DatabaseInstaller.php b/base/DatabaseInstaller.php index 578f051..82e0032 100644 --- a/base/DatabaseInstaller.php +++ b/base/DatabaseInstaller.php @@ -15,14 +15,13 @@ final class DatabaseInstaller { private ?string $username; private ?string $password = null; - public function __construct(private PerfOptions $options): void { - } + public function __construct(private PerfOptions $options): void {} - public function getUsername() : ?string { + public function getUsername(): ?string { return $this->username ? $this->username : $this->databaseName; } - public function getPassword() : ?string { + public function getPassword(): ?string { return $this->password !== null ? $this->password : $this->databaseName; } @@ -41,7 +40,7 @@ public function installDatabase(): bool { $dump = $this->dumpFile; invariant( $db !== null && $dump !== null, - 'database and dump must be specified' + 'database and dump must be specified', ); if ($this->options->skipDatabaseInstall) { $this->checkMySQLConnectionLimit(); @@ -61,19 +60,14 @@ public function installDatabase(): bool { } shell_exec( - Utils::EscapeCommand(Vector { - $this->options->dumpIsCompressed ? 'zcat' : 'cat', - $dump, - }). + Utils::EscapeCommand( + Vector {$this->options->dumpIsCompressed ? 'zcat' : 'cat', $dump}, + ). '|'. - $sed . - Utils::EscapeCommand(Vector { - 'mysql', - '-h', '127.0.0.1', - $db, - '-u', $db, - '-p'.$db - }) + $sed. + Utils::EscapeCommand( + Vector {'mysql', '-h', '127.0.0.1', $db, '-u', $db, '-p'.$db}, + ), ); return true; } @@ -85,40 +79,32 @@ private function getRootConnection(): resource { $this->password = trim(fgets(STDIN)); $conn = mysql_connect('127.0.0.1', $this->username, $this->password); if ($conn === false) { - throw new Exception( - 'Failed to connect: '.mysql_error() - ); + throw new Exception('Failed to connect: '.mysql_error()); } return $conn; } private function checkMySQLConnectionLimit(): void { - $conn = mysql_connect( - '127.0.0.1', $this->getUsername(), $this->getPassword() - ); + $conn = + mysql_connect('127.0.0.1', $this->getUsername(), $this->getPassword()); if ($conn === false) { - throw new Exception( - 'Failed to connect: '.mysql_error() - ); + throw new Exception('Failed to connect: '.mysql_error()); } $data = mysql_fetch_assoc( mysql_query( "SHOW variables WHERE Variable_name = 'max_connections'", - $conn - ) + $conn, + ), ); mysql_close($conn); if ($data['Value'] < 1000) { fprintf( STDERR, "Connection limit is too low - some benchmarks will have connection ". - "errors. This can be fixed for you..\n" + "errors. This can be fixed for you..\n", ); $conn = $this->getRootConnection(); - mysql_query( - 'SET GLOBAL max_connections = 1000', - $conn - ); + mysql_query('SET GLOBAL max_connections = 1000', $conn); mysql_close($conn); } } @@ -131,7 +117,7 @@ private function createMySQLDatabase(): void { '%s', "Can't connect to database ". "(mysql -h 127.0.0.1 -p$db -u $db $db). This can be ". - "fixed for you.\n" + "fixed for you.\n", ); $conn = $this->getRootConnection(); $edb = mysql_real_escape_string($db); @@ -146,8 +132,14 @@ private function createMySQLDatabase(): void { * grant */ mysql_query( - 'GRANT ALL PRIVILEGES ON '.$edb.'.* TO "'.$edb.'"@"%" '. - 'IDENTIFIED BY "'.$edb.'"', + 'GRANT ALL PRIVILEGES ON '. + $edb. + '.* TO "'. + $edb. + '"@"%" '. + 'IDENTIFIED BY "'. + $edb. + '"', $conn, ); mysql_query( diff --git a/base/HHVMDaemon.php b/base/HHVMDaemon.php index fe20a7a..ccd5c74 100644 --- a/base/HHVMDaemon.php +++ b/base/HHVMDaemon.php @@ -13,9 +13,7 @@ final class HHVMDaemon extends PHPEngine { private PerfTarget $target; private string $serverType; - public function __construct( - private PerfOptions $options, - ) { + public function __construct(private PerfOptions $options) { $this->target = $options->getTarget(); parent::__construct((string) $options->hhvm); @@ -25,10 +23,11 @@ public function __construct( $check_command = implode( ' ', (Vector { - $options->hhvm, - '-v', 'Eval.Jit=1', - __DIR__.'/hhvm_config_check.php', - })->map($x ==> escapeshellarg($x)) + $options->hhvm, + '-v', + 'Eval.Jit=1', + __DIR__.'/hhvm_config_check.php', + })->map($x ==> escapeshellarg($x)), ); if ($options->traceSubProcess) { fprintf(STDERR, "%s\n", $check_command); @@ -45,7 +44,7 @@ public function __construct( 'supported in 3.4.0-dev or later - detected %s. Please make sure '. 'that your HHVM build is a release build, and is built against '. "libpcre with JIT support.\n", - $version + $version, ); sleep(2); return; @@ -55,10 +54,10 @@ public function __construct( $options, (string) $options->hhvm, $checks, - Set { 'HHVM_VERSION' }, + Set {'HHVM_VERSION'}, ); } - + protected function getTarget(): PerfTarget { return $this->target; } @@ -66,58 +65,80 @@ protected function getTarget(): PerfTarget { <<__Override>> protected function getArguments(): Vector { $args = Vector { - '-m', 'server', - '-p', (string) PerfSettings::BackendPort(), - '-v', 'AdminServer.Port='.PerfSettings::BackendAdminPort(), - '-v', 'Server.Type='.$this->serverType, - '-v', 'Server.DefaultDocument=index.php', - '-v', 'Server.ErrorDocument404=index.php', - '-v', 'Server.SourceRoot='.$this->target->getSourceRoot(), - '-v', 'Eval.Jit=1', - '-d', 'pid='.escapeshellarg($this->getPidFilePath()), - '-c', OSS_PERFORMANCE_ROOT.'/conf/php.ini', + '-m', + 'server', + '-p', + (string) PerfSettings::BackendPort(), + '-v', + 'AdminServer.Port='.PerfSettings::BackendAdminPort(), + '-v', + 'Server.Type='.$this->serverType, + '-v', + 'Server.DefaultDocument=index.php', + '-v', + 'Server.ErrorDocument404=index.php', + '-v', + 'Server.SourceRoot='.$this->target->getSourceRoot(), + '-v', + 'Eval.Jit=1', + '-d', + 'pid='.escapeshellarg($this->getPidFilePath()), + '-c', + OSS_PERFORMANCE_ROOT.'/conf/php.ini', }; if ($this->options->pcreCache) { - $args->addAll(Vector { - '-v', 'Eval.PCRECacheType='.$this->options->pcreCache - }); + $args->addAll( + Vector {'-v', 'Eval.PCRECacheType='.$this->options->pcreCache}, + ); } if ($this->options->pcreSize) { - $args->addAll(Vector { - '-v', 'Eval.PCRETableSize='.$this->options->pcreSize - }); + $args->addAll( + Vector {'-v', 'Eval.PCRETableSize='.$this->options->pcreSize}, + ); } if ($this->options->pcreExpire) { - $args->addAll(Vector { - '-v', 'Eval.PCREExpireInterval='.$this->options->pcreExpire - }); + $args->addAll( + Vector { + '-v', + 'Eval.PCREExpireInterval='.$this->options->pcreExpire, + }, + ); } if (count($this->options->hhvmExtraArguments) > 0) { $args->addAll($this->options->hhvmExtraArguments); } if ($this->options->precompile) { - $bcRepo = $this->options->tempDir . '/hhvm.hhbc'; - $args->add('-v'); $args->add('Repo.Authoritative=true'); - $args->add('-v'); $args->add('Repo.Central.Path=' . $bcRepo); + $bcRepo = $this->options->tempDir.'/hhvm.hhbc'; + $args->add('-v'); + $args->add('Repo.Authoritative=true'); + $args->add('-v'); + $args->add('Repo.Central.Path='.$bcRepo); } if ($this->options->filecache) { $sourceRoot = $this->getTarget()->getSourceRoot(); - $staticContent = $this->options->tempDir . '/static.content'; - $args->add('-v'); $args->add('Server.FileCache=' . $staticContent); - $args->add('-v'); $args->add('Server.SourceRoot=' . $sourceRoot); + $staticContent = $this->options->tempDir.'/static.content'; + $args->add('-v'); + $args->add('Server.FileCache='.$staticContent); + $args->add('-v'); + $args->add('Server.SourceRoot='.$sourceRoot); } if ($this->options->tcprint !== null) { - $args->add('-v'); $args->add('Eval.JitTransCounters=true'); - $args->add('-v'); $args->add('Eval.DumpTC=true'); + $args->add('-v'); + $args->add('Eval.JitTransCounters=true'); + $args->add('-v'); + $args->add('Eval.DumpTC=true'); } if ($this->options->profBC) { - $args->add('-v'); $args->add('Eval.ProfileBC=true'); + $args->add('-v'); + $args->add('Eval.ProfileBC=true'); } if ($this->options->interpPseudomains) { - $args->add('-v'); $args->add('Eval.JitPseudomain=false'); + $args->add('-v'); + $args->add('Eval.JitPseudomain=false'); } if ($this->options->allVolatile) { - $args->add('-v'); $args->add('Eval.AllVolatile=true'); + $args->add('-v'); + $args->add('Eval.AllVolatile=true'); } return $args; } @@ -136,36 +157,43 @@ public function start(): void { $args = Vector { $hhvm, '--hphp', - '--target', 'hhbc', - '--output-dir', $this->options->tempDir, - '--input-dir', $sourceRoot, - '--module', '/', - '--cmodule', '/', + '--target', + 'hhbc', + '--output-dir', + $this->options->tempDir, + '--input-dir', + $sourceRoot, + '--module', + '/', + '--cmodule', + '/', '-l3', '-k1', }; if ($this->options->allVolatile) { - $args->add('-v'); $args->add('AllVolatile=true'); + $args->add('-v'); + $args->add('AllVolatile=true'); } invariant(is_dir($sourceRoot), 'Could not find valid source root'); $dir_iter = new RecursiveDirectoryIterator($sourceRoot); - $iter = new RecursiveIteratorIterator($dir_iter); + $iter = new RecursiveIteratorIterator($dir_iter); foreach ($iter as $path => $_) { // Source files not ending in .php need to be specifically included if (is_file($path) && substr($path, -4) !== '.php') { $contents = file_get_contents($path); if (strpos($contents, 'add($arg); } } } - $bcRepo = $this->options->tempDir . '/hhvm.hhbc'; - $staticContent = $this->options->tempDir . '/static.content'; + $bcRepo = $this->options->tempDir.'/hhvm.hhbc'; + $staticContent = $this->options->tempDir.'/static.content'; if (file_exists($bcRepo)) { unlink($bcRepo); } @@ -175,7 +203,7 @@ public function start(): void { unlink($staticContent); } $args->add('--file-cache'); - $args->add($this->options->tempDir . '/static.content'); + $args->add($this->options->tempDir.'/static.content'); } Utils::RunCommand($args); @@ -183,7 +211,7 @@ public function start(): void { invariant(file_exists($bcRepo), 'Failed to create bytecode repo'); invariant( !$this->options->filecache || file_exists($staticContent), - 'Failed to create static content cache' + 'Failed to create static content cache', ); } @@ -208,7 +236,7 @@ public function start(): void { } $health = json_decode($health, /* assoc array = */ true); if (array_key_exists('tc-size', $health) && - ($health['tc-size'] > 0 || $health['tc-hotsize'] > 0)) { + ($health['tc-size'] > 0 || $health['tc-hotsize'] > 0)) { return; } } @@ -239,31 +267,29 @@ public function stop(): void { if ($this->isRunning() && $pid !== null) { posix_kill($pid, SIGKILL); } - invariant( - $this->waitForStop(1, 0.1), - "HHVM is unstoppable!", - ); + invariant($this->waitForStop(1, 0.1), "HHVM is unstoppable!"); } public function writeStats(): void { $tcprint = $this->options->tcprint; if ($tcprint) { - $conf = $this->options->tempDir . '/conf.hdf'; + $conf = $this->options->tempDir.'/conf.hdf'; $args = Vector {}; - $hdf = false; + $hdf = false; foreach ($this->getArguments() as $arg) { - if ($hdf) $args->add($arg); + if ($hdf) + $args->add($arg); $hdf = $arg === '-v'; } $confData = implode("\n", $args); file_put_contents($conf, $confData); - $args = Vector { $tcprint, '-c', $conf }; + $args = Vector {$tcprint, '-c', $conf}; $result = $this->adminRequest('/vm-dump-tc'); invariant( $result === 'Done' && file_exists('/tmp/tc_dump_a'), - 'Failed to dump TC' + 'Failed to dump TC', ); if ($this->options->tcAlltrans) { @@ -273,14 +299,16 @@ public function writeStats(): void { if ($this->options->tcToptrans) { $new_args = new Vector($args); - $new_args->add('-t'); $new_args->add('100'); + $new_args->add('-t'); + $new_args->add('100'); $toptrans = Utils::RunCommand($new_args); file_put_contents('tc-top-trans', $toptrans); } if ($this->options->tcTopfuncs) { $new_args = new Vector($args); - $new_args->add('-T'); $new_args->add('100'); + $new_args->add('-T'); + $new_args->add('100'); $topfuncs = Utils::RunCommand($new_args); file_put_contents('tc-top-funcs', $topfuncs); } @@ -290,31 +318,28 @@ public function writeStats(): void { $result = $this->adminRequest('/dump-pcre-cache'); invariant( $result === "OK\n" && file_exists('/tmp/pcre_cache'), - 'Failed to dump PCRE cache' + 'Failed to dump PCRE cache', ); // move dump to CWD - rename('/tmp/pcre_cache', getcwd() . '/pcre_cache'); + rename('/tmp/pcre_cache', getcwd().'/pcre_cache'); } } protected function adminRequest( string $path, - bool $allowFailures = true + bool $allowFailures = true, ): string { $url = 'http://localhost:'.PerfSettings::HttpAdminPort().$path; $ctx = stream_context_create( - ['http' => ['timeout' => $this->options->maxdelayAdminRequest]] + ['http' => ['timeout' => $this->options->maxdelayAdminRequest]], ); // // TODO: it would be nice to suppress // Warning messages from file_get_contents // in the event that the connection can't even be made. // - $result = file_get_contents( - $url, - /* include path = */ false, - $ctx); + $result = file_get_contents($url, /* include path = */ false, $ctx); if ($result !== false) { return $result; } @@ -327,9 +352,7 @@ protected function adminRequest( } protected function getEnvironmentVariables(): Map { - return Map { - 'OSS_PERF_TARGET' => (string) $this->target, - }; + return Map {'OSS_PERF_TARGET' => (string) $this->target}; } public function __toString(): string { diff --git a/base/NginxDaemon.php b/base/NginxDaemon.php index 9a69100..5b0ee87 100644 --- a/base/NginxDaemon.php +++ b/base/NginxDaemon.php @@ -2,7 +2,6 @@ /* * Copyright (c) 2014, Facebook, Inc. * All rights reserved. - * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. @@ -30,7 +29,7 @@ public function clearAccessLog(): void { $log = $this->options->tempDir.'/access.log'; invariant( file_exists($log), - 'access log does not exist, but attempted to clear it' + 'access log does not exist, but attempted to clear it', ); $pid = $this->getPid(); if ($pid !== null) { @@ -45,7 +44,7 @@ public function collectStats(): Map> { $combined_time = 0; $combined_bytes = 0; - $page_results = Map { }; + $page_results = Map {}; // Custom format: '$status $body_bytes_sent $request_time "$request"' $log = file_get_contents($this->options->tempDir.'/access.log'); @@ -55,7 +54,7 @@ public function collectStats(): Map> { $request = explode('"', $entry)[1]; $entries_by_request[$request][] = $entry; } - $combined_times = Vector { }; + $combined_times = Vector {}; foreach ($entries_by_request as $request => $entries) { $request_hits = count($entries); @@ -65,7 +64,7 @@ public function collectStats(): Map> { 'Nginx avg bytes' => 0, 'Nginx avg time' => 0, }; - $times = Vector { }; + $times = Vector {}; foreach ($entries as $entry) { $parts = explode(' ', $entry); @@ -112,12 +111,14 @@ protected function getPidFilePath(): string { <<__Override>> protected function getArguments(): Vector { return Vector { - '-c', $this->getGeneratedConfigFile(), + '-c', + $this->getGeneratedConfigFile(), // // Watch out! The -g arguments to nginx do not accumulate. // The last one wins, and is the only one evaluated by nginx. // - '-g', 'daemon off;', + '-g', + 'daemon off;', }; } @@ -134,10 +135,8 @@ protected function getGeneratedConfigFile(): string { PerfSettings::BackendAdminPort(), ); } else { - $proxy_pass = sprintf( - 'fastcgi_pass 127.0.0.1:%d', - PerfSettings::BackendPort(), - ); + $proxy_pass = + sprintf('fastcgi_pass 127.0.0.1:%d', PerfSettings::BackendPort()); $admin_proxy_pass = sprintf( 'fastcgi_pass 127.0.0.1:%d', PerfSettings::BackendAdminPort(), @@ -153,17 +152,16 @@ protected function getGeneratedConfigFile(): string { '__NGINX_CONFIG_ROOT__' => OSS_PERFORMANCE_ROOT.'/conf/nginx', '__NGINX_TEMP_DIR__' => $this->options->tempDir, '__NGINX_KEEPALIVE_TIMEOUT__' => - (int)$this->options->maxdelayNginxKeepAlive, + (int) $this->options->maxdelayNginxKeepAlive, '__NGINX_FASTCGI_READ_TIMEOUT__' => - (int)$this->options->maxdelayNginxFastCGI, + (int) $this->options->maxdelayNginxFastCGI, '__FRAMEWORK_ROOT__' => $this->target->getSourceRoot(), '__NGINX_PID_FILE__' => $this->getPidFilePath(), '__DATE__' => date(DATE_W3C), }; - $config = file_get_contents( - OSS_PERFORMANCE_ROOT.'/conf/nginx/nginx.conf.in' - ); + $config = + file_get_contents(OSS_PERFORMANCE_ROOT.'/conf/nginx/nginx.conf.in'); foreach ($substitutions as $find => $replace) { $config = str_replace($find, $replace, $config); } diff --git a/base/PHP5Daemon.php b/base/PHP5Daemon.php index 61d3bb2..f6a0ed1 100644 --- a/base/PHP5Daemon.php +++ b/base/PHP5Daemon.php @@ -12,9 +12,7 @@ final class PHP5Daemon extends PHPEngine { private PerfTarget $target; - public function __construct( - private PerfOptions $options, - ) { + public function __construct(private PerfOptions $options) { $this->target = $options->getTarget(); parent::__construct((string) $options->php5); @@ -22,11 +20,12 @@ public function __construct( $check_command = implode( ' ', (Vector { - $options->php5, - '-q', - '-c', OSS_PERFORMANCE_ROOT.'/conf', - __DIR__.'/php-src_config_check.php', - })->map($x ==> escapeshellarg($x)) + $options->php5, + '-q', + '-c', + OSS_PERFORMANCE_ROOT.'/conf', + __DIR__.'/php-src_config_check.php', + })->map($x ==> escapeshellarg($x)), ); if ($options->traceSubProcess) { @@ -39,7 +38,7 @@ public function __construct( $options, (string) $options->php5, $checks, - Set { 'PHP_VERSION', 'PHP_VERSION_ID' }, + Set {'PHP_VERSION', 'PHP_VERSION_ID'}, ); } @@ -53,8 +52,10 @@ public function start(): void { protected function getArguments(): Vector { $args = Vector { - '-b', '127.0.0.1:'.PerfSettings::BackendPort(), - '-c', OSS_PERFORMANCE_ROOT.'/conf/', + '-b', + '127.0.0.1:'.PerfSettings::BackendPort(), + '-c', + OSS_PERFORMANCE_ROOT.'/conf/', }; if (count($this->options->phpExtraArguments) > 0) { diff --git a/base/PerfOptions.php b/base/PerfOptions.php index c329575..4113be4 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -66,12 +66,12 @@ final class PerfOptions { // HHVM specific options for generating performance data and profiling // information. // - public ?string $tcprint = null; + public ?string $tcprint = null; public bool $tcAlltrans = false; public bool $tcToptrans = false; public bool $tcTopfuncs = false; public bool $pcredump = false; - public bool $profBC = false; + public bool $profBC = false; public bool $applyPatches = false; @@ -85,8 +85,8 @@ final class PerfOptions { // public float $delayNginxStartup; public float $delayPhpStartup; - public float $delayProcessLaunch; // secs to wait after start process - public float $delayCheckHealth; // secs to wait before hit /check-health + public float $delayProcessLaunch; // secs to wait after start process + public float $delayCheckHealth; // secs to wait before hit /check-health // // Maximum wait times, as for example given to file_get_contents @@ -105,21 +105,17 @@ final class PerfOptions { public bool $notBenchmarking = false; private array $args; - private Vector $notBenchmarkingArgs = Vector { }; + private Vector $notBenchmarkingArgs = Vector {}; public function __construct(Vector $argv) { $def = Vector { 'help', - 'verbose', - 'php5:', 'hhvm:', 'siege:', 'nginx:', - 'wait-at-end', - 'no-proxygen', 'no-repo-auth', 'no-file-cache', @@ -128,49 +124,38 @@ public function __construct(Vector $argv) { 'pcre-cache-size:', 'all-volatile', 'interp-pseudomains', - 'apply-patches', - 'force-innodb', 'fbcode::', - 'tcprint::', 'dump-top-trans', 'dump-top-funcs', 'dump-all-trans', 'dump-pcre-cache', 'profBC', - 'setUpTest:', 'tearDownTest:', - 'i-am-not-benchmarking', - 'hhvm-extra-arguments:', 'php-extra-arguments:', 'php-fcgi-children:', - 'no-time-limit', - 'skip-sanity-check', 'skip-warmup', 'skip-version-checks', 'skip-database-install', 'trace', - 'delay-nginx-startup:', 'delay-php-startup:', 'delay-process-launch:', 'delay-check-health:', - 'max-delay-unfreeze:', 'max-delay-admin-request:', 'max-delay-nginx-keepalive:', 'max-delay-nginx-fastcgi:', - - '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 + '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 }; $targets = $this->getTargetDefinitions()->keys(); $def->addAll($targets); @@ -186,14 +171,17 @@ public function __construct(Vector $argv) { STDERR, "Usage: %s \\\n". " --\\\n". - " --<".implode('|',$targets).">\n". + " --<". + implode('|', $targets). + ">\n". "\n". "Options:\n%s", $argv[0], implode('', $def->map($x ==> ' --'.$x."\n")), ); exit(1); - }; + } + ; $this->verbose = array_key_exists('verbose', $o); $this->php5 = hphp_array_idx($o, 'php5', null); @@ -212,7 +200,7 @@ public function __construct(Vector $argv) { if (is_string($val) && $val !== '') { $fbcode = $val; } else { - $fbcode = getenv('HOME') . '/fbcode'; + $fbcode = getenv('HOME').'/fbcode'; } $this->forceInnodb = true; } @@ -235,7 +223,7 @@ public function __construct(Vector $argv) { $this->proxygen = !$this->getBool('no-proxygen'); $this->applyPatches = $this->getBool('apply-patches'); - $this->precompile = !$this->getBool('no-repo-auth'); + $this->precompile = !$this->getBool('no-repo-auth'); $this->filecache = $this->precompile && !$this->getBool('no-file-cache'); $this->pcreCache = $this->getNullableString('pcre-cache'); $this->pcreSize = $this->getNullableInt('pcre-cache-size'); @@ -249,7 +237,7 @@ public function __construct(Vector $argv) { $this->tcprint = $tcprint; } else if ($isFacebook) { $this->tcprint = - $fbcode . '/_bin/hphp/facebook/tools/tc-print/tc-print'; + $fbcode.'/_bin/hphp/facebook/tools/tc-print/tc-print'; } } $this->tcAlltrans = $this->getBool('dump-all-trans'); @@ -259,13 +247,12 @@ public function __construct(Vector $argv) { $this->profBC = $this->getBool('profBC'); $this->forceInnodb = $isFacebook || $this->getBool('force-innodb'); - if ($this->tcprint !== null && - !$this->tcTopfuncs && !$this->tcToptrans) { + if ($this->tcprint !== null && !$this->tcTopfuncs && !$this->tcToptrans) { $this->tcAlltrans = true; } if ($isFacebook && $this->php5 === null && $this->hhvm === null) { - $this->hhvm = $fbcode . '/_bin/hphp/hhvm/hhvm'; + $this->hhvm = $fbcode.'/_bin/hphp/hhvm/hhvm'; } $this->traceSubProcess = $this->getBool('trace'); @@ -279,18 +266,12 @@ public function __construct(Vector $argv) { $this->delayProcessLaunch = $this->getFloat('delay-process-launch', 0.0); $this->delayCheckHealth = $this->getFloat('delay-check-health', 1.0); $this->maxdelayUnfreeze = $this->getFloat('max-delay-unfreeze', 60.0); - $this->maxdelayAdminRequest = $this->getFloat( - 'max-delay-admin-request', - 3.0 - ); - $this->maxdelayNginxKeepAlive = $this->getFloat( - 'max-delay-nginx-keep-alive', - 60.0 - ); - $this->maxdelayNginxFastCGI = $this->getFloat( - 'max-delay-nginx-fastcgi', - 60.0 - ); + $this->maxdelayAdminRequest = + $this->getFloat('max-delay-admin-request', 3.0); + $this->maxdelayNginxKeepAlive = + $this->getFloat('max-delay-nginx-keep-alive', 60.0); + $this->maxdelayNginxFastCGI = + $this->getFloat('max-delay-nginx-fastcgi', 60.0); $this->daemonOutputToFile = $this->getBool('daemon-files'); @@ -318,7 +299,7 @@ public function validate() { if ($this->notBenchmarkingArgs && !$this->notBenchmarking) { $message = sprintf( "These arguments are invalid without --i-am-not-benchmarking: %s", - implode(' ', $this->notBenchmarkingArgs) + implode(' ', $this->notBenchmarkingArgs), ); if (getenv("HHVM_OSS_PERF_BE_LENIENT")) { fprintf(STDERR, "*** WARNING ***\n%s\n", $message); @@ -331,19 +312,19 @@ public function validate() { if ($this->php5 === null && $this->hhvm === null) { invariant_violation( 'Either --php5=/path/to/php-cgi or --hhvm=/path/to/hhvm '. - "must be specified" + "must be specified", ); } $engine = $this->php5 !== null ? $this->php5 : $this->hhvm; invariant( - shell_exec('which '.escapeshellarg($engine)) !== null - || is_executable($engine), + shell_exec('which '.escapeshellarg($engine)) !== null || + is_executable($engine), 'Invalid engine: %s', - $engine + $engine, ); invariant( - shell_exec('which '.escapeshellarg($this->siege)) !== null - || is_executable($this->siege), + shell_exec('which '.escapeshellarg($this->siege)) !== null || + is_executable($this->siege), 'Could not find siege', ); @@ -351,32 +332,32 @@ public function validate() { if ($tcprint !== null) { invariant( $tcprint !== '' && - (shell_exec('which '.escapeshellarg($tcprint)) !== null - || is_executable($tcprint)), + (shell_exec('which '.escapeshellarg($tcprint)) !== null || + is_executable($tcprint)), 'Invalid tcprint: %s', - $tcprint + $tcprint, ); } if ($this->tcAlltrans || $this->tcToptrans || $this->tcTopfuncs) { invariant( $tcprint !== null, - '--tcprint=/path/to/tc-print must be specified if --tc-all-trans, ' . - '--tc-top-trans, or --tc-top-funcs are specified' + '--tcprint=/path/to/tc-print must be specified if --tc-all-trans, '. + '--tc-top-trans, or --tc-top-funcs are specified', ); } if ($this->pcreCache !== null || $this->pcreSize || $this->pcreExpire) { invariant( $this->hhvm !== null, - 'The PCRE caching scheme can only be tuned for hhvm' + 'The PCRE caching scheme can only be tuned for hhvm', ); } if ($this->precompile) { invariant( $this->hhvm !== null, - 'Only hhvm can be used with --repo-auth' + 'Only hhvm can be used with --repo-auth', ); } @@ -419,14 +400,11 @@ private function getArray(string $name): array { } } - private function getInt( - string $index, - int $the_default, - ): int { + private function getInt(string $index, int $the_default): int { if (array_key_exists($index, $this->args)) { $this->notBenchmarkingArgs[] = '--'.$index; } - return (int ) hphp_array_idx($this->args, $index, $the_default); + return (int) hphp_array_idx($this->args, $index, $the_default); } private function getNullableInt(string $name): ?int { @@ -437,14 +415,11 @@ private function getNullableInt(string $name): ?int { return $this->args[$name]; } - private function getFloat( - string $index, - float $the_default, - ): float { + private function getFloat(string $index, float $the_default): float { if (array_key_exists($index, $this->args)) { $this->notBenchmarkingArgs[] = '--'.$index; } - return (float)hphp_array_idx($this->args, $index, $the_default); + return (float) hphp_array_idx($this->args, $index, $the_default); } // @@ -454,8 +429,11 @@ private function getFloat( // public function daemonOutputFileName(string $daemonName): ?string { if ($this->daemonOutputToFile) { - return (($this->tempDir === null) ? '/tmp' : $this->tempDir) - . '/' . $daemonName . '.out'; + return + (($this->tempDir === null) ? '/tmp' : $this->tempDir). + '/'. + $daemonName. + '.out'; } else { return null; } @@ -479,7 +457,7 @@ public function getTarget(): PerfTarget { fprintf( STDERR, "You must specify a target with exactly one of the following:\n". - implode('', $def->keys()->map($arg ==> ' --'.$arg."\n")) + implode('', $def->keys()->map($arg ==> ' --'.$arg."\n")), ); exit(1); } @@ -501,7 +479,7 @@ private function getTargetDefinitions( 'toys-fibonacci' => () ==> new FibonacciTarget(), 'toys-hello-world' => () ==> new HelloWorldTarget(), 'wordpress' => () ==> new WordpressTarget($this), - 'magento1' => () ==> new Magento1Target($this) + 'magento1' => () ==> new Magento1Target($this), }; } } diff --git a/base/PerfRunner.php b/base/PerfRunner.php index 4e84031..ec61cb4 100644 --- a/base/PerfRunner.php +++ b/base/PerfRunner.php @@ -12,16 +12,12 @@ type PerfResult = Map>; final class PerfRunner { - public static function RunWithArgv( - Vector $argv, - ): PerfResult { + public static function RunWithArgv(Vector $argv): PerfResult { $options = new PerfOptions($argv); return self::RunWithOptions($options); } - public static function RunWithOptions( - PerfOptions $options, - ): PerfResult { + public static function RunWithOptions(PerfOptions $options): PerfResult { // If we exit cleanly, Process::__destruct() gets called, but it doesn't // if we're killed by Ctrl-C. This tends to leak php-cgi or hhvm processes - // trap the signal so we can clean them up. @@ -30,7 +26,7 @@ public static function RunWithOptions( function() { Process::cleanupAll(); exit(); - } + }, ); $php_engine = null; @@ -64,13 +60,15 @@ private static function RunWithOptionsAndEngine( $target->postInstall(); if ($options->setUpTest != null) { - $command = "OSS_PERF_PHASE=" . "setUp" - . " " . "OSS_PERF_TARGET=" . (string) $target - . " " . $options->setUpTest - ; - self::PrintProgress('Starting setUpTest ' . $command); + $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); + self::PrintProgress('Finished setUpTest '.$command); } else { self::PrintProgress('There is no setUpTest'); } @@ -86,7 +84,7 @@ private static function RunWithOptionsAndEngine( Process::sleepSeconds($options->delayPhpStartup); invariant( $php_engine->isRunning(), - 'Failed to start '.get_class($php_engine) + 'Failed to start '.get_class($php_engine), ); if ($target->needsUnfreeze()) { @@ -109,7 +107,10 @@ private static function RunWithOptionsAndEngine( $siege->wait(); invariant(!$siege->isRunning(), 'Siege is still running :/'); - invariant($php_engine->isRunning(), get_class($php_engine).' crashed'); + invariant( + $php_engine->isRunning(), + get_class($php_engine).' crashed', + ); } else { self::PrintProgress('Skipping single request warmup'); } @@ -122,7 +123,10 @@ private static function RunWithOptionsAndEngine( $siege->wait(); invariant(!$siege->isRunning(), 'Siege is still running :/'); - invariant($php_engine->isRunning(), get_class($php_engine).' crashed'); + invariant( + $php_engine->isRunning(), + get_class($php_engine).' crashed', + ); } else { self::PrintProgress('Skipping multi request warmup'); } @@ -138,7 +142,7 @@ private static function RunWithOptionsAndEngine( self::PrintProgress('Collecting results'); - $combined_stats = Map { }; + $combined_stats = Map {}; $siege_stats = $siege->collectStats(); foreach ($siege_stats as $page => $stats) { if ($combined_stats->containsKey($page)) { @@ -158,13 +162,13 @@ private static function RunWithOptionsAndEngine( } if (!$options->verbose) { - $combined_stats = $combined_stats->filterWithKey( - ($k, $v) ==> $k === 'Combined' - ); + $combined_stats = + $combined_stats->filterWithKey(($k, $v) ==> $k === 'Combined'); } else { ksort($combined_stats); } - $combined_stats['Combined']['canonical'] = (int) !$options->notBenchmarking; + $combined_stats['Combined']['canonical'] = + (int) !$options->notBenchmarking; self::PrintProgress('Collecting TC/PCRE data'); $php_engine->writeStats(); @@ -176,13 +180,15 @@ 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); + $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); + self::PrintProgress('Finished tearDownTest '.$command); } else { self::PrintProgress('There is no tearDownTest'); } diff --git a/base/PerfTarget.php b/base/PerfTarget.php index 8598b92..1ce9b2d 100644 --- a/base/PerfTarget.php +++ b/base/PerfTarget.php @@ -10,7 +10,7 @@ */ abstract class PerfTarget { - public function install(): void { } + public function install(): void {} abstract protected function getSanityCheckString(): string; abstract public function getSourceRoot(): string; @@ -20,28 +20,28 @@ protected function getSanityCheckPath(): string { } final public function sanityCheck(): void { - $ctx = stream_context_create( - ['http' => ['timeout' => 30]] - ); - $url = 'http://'.gethostname().':'.PerfSettings::HttpPort(). + $ctx = stream_context_create(['http' => ['timeout' => 30]]); + $url = + 'http://'. + gethostname(). + ':'. + PerfSettings::HttpPort(). $this->getSanityCheckPath(); $content = file_get_contents($url, /* include path = */ false, $ctx); invariant( strstr($content, $this->getSanityCheckString()) !== false, - 'Failed to find string "'.$this->getSanityCheckString().'" in '. - $url + 'Failed to find string "'.$this->getSanityCheckString().'" in '.$url, ); } <<__Memoize>> - final protected function getAssetsDirectory(): string{ + final protected function getAssetsDirectory(): string { $class = get_class($this); $file = (new ReflectionClass($class))->getFileName(); return dirname($file); } - public function postInstall(): void { - } + public function postInstall(): void {} final public function applyPatches(): void { $dir = $this->getAssetsDirectory().'/patches/'; @@ -92,7 +92,7 @@ public function needsUnfreeze(): bool { public function unfreeze(PerfOptions $options): void { invariant_violation( - 'If you override needsUnfreeze(), you must override unfreeze() too.' + 'If you override needsUnfreeze(), you must override unfreeze() too.', ); } diff --git a/base/Process.php b/base/Process.php index 0fb27e5..755a853 100644 --- a/base/Process.php +++ b/base/Process.php @@ -26,12 +26,12 @@ final public static function cleanupAll() { foreach (self::$processes as $process) { $process->__destruct(); } - self::$processes = Vector { }; + self::$processes = Vector {}; } abstract protected function getArguments(): Vector; protected function getEnvironmentVariables(): Map { - return Map { }; + return Map {}; } public function getExecutablePath(): string { @@ -47,19 +47,20 @@ public function startWorker( ): void { $executable = $this->getExecutablePath(); - $this->command = $executable.' '.implode( - ' ', - $this->getArguments()->map($x ==> escapeshellarg($x)), - ); + $this->command = + $executable. + ' '. + implode(' ', $this->getArguments()->map($x ==> escapeshellarg($x))); if ($this->suppress_stdout) { $this->command .= ' >/dev/null'; } $use_pipe = ($outputFileName === null); - $spec = [ - 0 => ['pipe', 'r'], // stdin - 1 => $use_pipe ? ['pipe', 'w'] : ['file', $outputFileName, 'a'], // stdout + $spec = + [ + 0 => ['pipe', 'r'], // stdin + 1 => $use_pipe ? ['pipe', 'w'] : ['file', $outputFileName, 'a'], // stdout // not currently using file descriptor 2 (stderr) - ]; + ]; $pipes = []; $env = new Map($_ENV); $env->setAll($this->getEnvironmentVariables()); @@ -80,7 +81,7 @@ public function startWorker( invariant( $proc && proc_get_status($proc)['running'] === true, 'failed to start process: %s', - $this->command + $this->command, ); $this->process = $proc; diff --git a/base/Siege.php b/base/Siege.php index 8ba5128..0cc1922 100644 --- a/base/Siege.php +++ b/base/Siege.php @@ -24,7 +24,9 @@ public function __construct( if (!$options->skipVersionChecks) { $version_line = trim( - exec(escapeshellarg($options->siege).' --version 2>&1 | head -n 1') + exec( + escapeshellarg($options->siege).' --version 2>&1 | head -n 1', + ), ); $bad_prefix = 'SIEGE 3'; if (substr($version_line, 0, strlen($bad_prefix)) === $bad_prefix) { @@ -76,16 +78,9 @@ public function getExecutablePath(): string { protected function getArguments(): Vector { $urls_file = tempnam($this->options->tempDir, 'urls'); $urls = file_get_contents($this->target->getURLsFile()); - $urls = str_replace( - '__HTTP_PORT__', - (string) PerfSettings::HttpPort(), - $urls, - ); - $urls = str_replace( - '__HTTP_HOST__', - gethostname(), - $urls - ); + $urls = + str_replace('__HTTP_PORT__', (string) PerfSettings::HttpPort(), $urls); + $urls = str_replace('__HTTP_HOST__', gethostname(), $urls); file_put_contents($urls_file, $urls); $arguments = Vector {}; @@ -100,46 +95,58 @@ protected function getArguments(): Vector { } $siege_rc = $this->target->getSiegeRCPath(); if ($siege_rc !== null) { - $arguments->addAll(Vector { - '-R', $siege_rc, - }); + $arguments->addAll(Vector {'-R', $siege_rc}); } switch ($this->mode) { case RequestModes::WARMUP: - $arguments->addAll(Vector { - '-c', (string) PerfSettings::WarmupConcurrency(), - '-r', (string) PerfSettings::WarmupRequests(), - '-f', $urls_file, - '--benchmark', - '--log=/dev/null', - }); + $arguments->addAll( + Vector { + '-c', + (string) PerfSettings::WarmupConcurrency(), + '-r', + (string) PerfSettings::WarmupRequests(), + '-f', + $urls_file, + '--benchmark', + '--log=/dev/null', + }, + ); return $arguments; case RequestModes::WARMUP_MULTI: - $arguments->addAll(Vector { - '-c', (string) PerfSettings::BenchmarkConcurrency(), - '-t', '1M', - '-f', $urls_file, - '--benchmark', - '--log=/dev/null', - }); + $arguments->addAll( + Vector { + '-c', + (string) PerfSettings::BenchmarkConcurrency(), + '-t', + '1M', + '-f', + $urls_file, + '--benchmark', + '--log=/dev/null', + }, + ); return $arguments; case RequestModes::BENCHMARK: - $arguments->addAll(Vector { - '-c', (string) PerfSettings::BenchmarkConcurrency(), - '-f', $urls_file, - '--benchmark', - '--log='.$this->logfile, - }); - - if (!$this->options->noTimeLimit) { + $arguments->addAll( + Vector { + '-c', + (string) PerfSettings::BenchmarkConcurrency(), + '-f', + $urls_file, + '--benchmark', + '--log='.$this->logfile, + }, + ); + + if (!$this->options->noTimeLimit) { $arguments->add('-t'); $arguments->add(PerfSettings::BenchmarkTime()); } return $arguments; default: invariant_violation( - 'Unexpected request mode: '.(string)$this->mode + 'Unexpected request mode: '.(string) $this->mode, ); } } @@ -148,7 +155,7 @@ protected function getLogFilePath(): string { $logfile = $this->logfile; invariant( $logfile !== null, - 'Tried to get log file path without a logfile' + 'Tried to get log file path without a logfile', ); return $logfile; } diff --git a/base/SiegeStats.php b/base/SiegeStats.php index dc1d4e0..6c20f53 100644 --- a/base/SiegeStats.php +++ b/base/SiegeStats.php @@ -13,14 +13,12 @@ trait SiegeStats { abstract protected function getLogFilePath(): string; public function collectStats(): Map> { - $log_lines = explode( - "\n", - trim(file_get_contents($this->getLogFilePath())) - ); + $log_lines = + explode("\n", trim(file_get_contents($this->getLogFilePath()))); invariant( count($log_lines) === 1, 'Expected 1 line in siege log file, got %d', - count($log_lines) + count($log_lines), ); $log_line = array_pop($log_lines); $data = (new Vector(explode(',', $log_line)))->map($x ==> trim($x)); @@ -31,7 +29,7 @@ public function collectStats(): Map> { 'Siege RPS' => (float) $data[SiegeFields::TRANSACTION_RATE], 'Siege successful requests' => (int) $data[SiegeFields::OKAY], 'Siege failed requests' => (int) $data[SiegeFields::FAILED], - } + }, }; } } diff --git a/base/SystemChecks.php b/base/SystemChecks.php index 5328c9e..1ae811f 100644 --- a/base/SystemChecks.php +++ b/base/SystemChecks.php @@ -25,7 +25,7 @@ private static function CheckForAuditd(PerfOptions $options): void { fprintf( STDERR, "WARNING: auditd is running, and can significantly skew ". - "benchmark and profiling results. Please disable it.\n" + "benchmark and profiling results. Please disable it.\n", ); sleep(3); return; @@ -33,7 +33,7 @@ private static function CheckForAuditd(PerfOptions $options): void { invariant_violation( "auditd is running, and can significantly skew benchmark and ". "profiling results. Either disable it, or pass ". - "--i-am-not-benchmarking to continue anyway." + "--i-am-not-benchmarking to continue anyway.", ); } } @@ -66,7 +66,7 @@ private static function CheckCPUFreq(): void { $gov = trim(file_get_contents($gov_file)); invariant( $gov === 'performance', - 'Unsuitable CPU speed policy - see cpufreq.md' + 'Unsuitable CPU speed policy - see cpufreq.md', ); } } @@ -78,7 +78,7 @@ private static function CheckPortAvailability(): void { PerfSettings::BackendPort(), PerfSettings::BackendAdminPort(), }; - $busy_ports = Vector { }; + $busy_ports = Vector {}; foreach ($ports as $port) { $result = @fsockopen('localhost', $port); if ($result !== false) { diff --git a/base/Utils.php b/base/Utils.php index f4c317a..97b288e 100644 --- a/base/Utils.php +++ b/base/Utils.php @@ -11,10 +11,7 @@ final class Utils { - public static function ExtractTar( - string $tar_file, - string $extract_to, - ) { + public static function ExtractTar(string $tar_file, string $extract_to) { // Wrong argument order? invariant(is_dir($extract_to), '%s is not a directory', $extract_to); $flags = null; @@ -23,28 +20,28 @@ public static function ExtractTar( } else if (substr($tar_file, -4) === '.bz2') { $flags = '-jxf'; } - invariant($flags !== null, "Couldn't guess compression for %s", $tar_file); - - shell_exec(self::EscapeCommand(Vector { - 'tar', - '-C', $extract_to, - $flags, + invariant( + $flags !== null, + "Couldn't guess compression for %s", $tar_file, - })); + ); + + shell_exec( + self::EscapeCommand( + Vector {'tar', '-C', $extract_to, $flags, $tar_file}, + ), + ); } - public static function CopyDirContents ( - string $from, - string $to, - ): void { + public static function CopyDirContents(string $from, string $to): void { invariant(is_dir($from), '%s is not a directory', $from); mkdir($to, 0777, true); $from_dir = opendir($from); while (($name = readdir($from_dir)) !== false) { if ($name != '.' && $name != '..') { - $from_name = $from . DIRECTORY_SEPARATOR . $name; - $to_name = $to . DIRECTORY_SEPARATOR . $name; - if (is_dir($from_name) ) { + $from_name = $from.DIRECTORY_SEPARATOR.$name; + $to_name = $to.DIRECTORY_SEPARATOR.$name; + if (is_dir($from_name)) { Utils::CopyDirContents($from_name, $to_name); } else { copy($from_name, $to_name); diff --git a/base/cli-init.php b/base/cli-init.php index 5d95f4a..981bb4b 100644 --- a/base/cli-init.php +++ b/base/cli-init.php @@ -19,11 +19,12 @@ const OSS_PERFORMANCE_ROOT = __DIR__.'/..'; if (!file_exists(OSS_PERFORMANCE_ROOT.'/vendor/autoload.php')) { fprintf( - STDERR, "%s\n", + STDERR, + "%s\n", 'Autoload map not found. Please install composer (see getcomposer.org), '. - 'and run "composer install" from this directory.' + 'and run "composer install" from this directory.', ); exit(1); } -require_once(OSS_PERFORMANCE_ROOT.'/vendor/autoload.php'); +require_once (OSS_PERFORMANCE_ROOT.'/vendor/autoload.php'); diff --git a/batch-run.php b/batch-run.php index 76df649..2df7cce 100644 --- a/batch-run.php +++ b/batch-run.php @@ -9,10 +9,11 @@ * */ -enum BatchRuntimeType: string { +enum BatchRuntimeType : string { HHVM = 'hhvm'; PHP_SRC = 'php-src'; -}; +} +; type BatchRuntime = shape( 'name' => string, @@ -33,13 +34,16 @@ 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 { }, + '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 {}, ); } @@ -48,12 +52,12 @@ function batch_get_target( Map $runtimes, Map> $overrides, ): BatchTarget { - $target_overrides = Map { }; + $target_overrides = Map {}; if ($overrides->containsKey($name)) { $target_overrides = $overrides[$name]; } - $target_runtimes = Vector { }; + $target_runtimes = Vector {}; foreach ($runtimes as $runtime_name => $runtime) { if ($target_overrides->containsKey($runtime_name)) { $runtime = $target_overrides[$runtime_name]; @@ -63,26 +67,21 @@ function batch_get_target( $target_runtimes[] = $runtime; } } - return shape( - 'name' => $name, - 'runtimes' => $target_runtimes, - ); + return shape('name' => $name, 'runtimes' => $target_runtimes); } function batch_get_targets(string $json_data): Vector { $data = json_decode($json_data, true, 512); if ($data === null) { - throw new Exception( - 'Invalid JSON: '.json_last_error_msg() - ); + throw new Exception('Invalid JSON: '.json_last_error_msg()); } - $runtimes = Map { }; + $runtimes = Map {}; foreach ($data['runtimes'] as $name => $runtime_data) { $runtimes[$name] = batch_get_runtime($name, $runtime_data); } - $overrides = Map { }; + $overrides = Map {}; if (array_key_exists('runtime-overrides', $data)) { foreach ($data['runtime-overrides'] as $target => $target_overrides) { foreach ($target_overrides as $name => $override_data) { @@ -93,7 +92,7 @@ function batch_get_targets(string $json_data): Vector { invariant( $runtimes->containsKey($name), 'Overriding a non-existing runtime "%s"', - $name + $name, ); $override = $runtimes[$name]; foreach ($override_data as $key => $value) { @@ -108,14 +107,14 @@ function batch_get_targets(string $json_data): Vector { invariant_violation("Can't override '%s'", $key); } if (!$overrides->containsKey($target)) { - $overrides[$target] = Map { }; + $overrides[$target] = Map {}; } $overrides[$target][$name] = $skip ? null : $override; } } } - $targets = Vector { }; + $targets = Vector {}; foreach ($data['targets'] as $target) { $targets[] = batch_get_target($target, $runtimes, $overrides); } @@ -154,7 +153,7 @@ function batch_get_all_runs_for_target( BatchTarget $target, Vector $argv, ): Map { - $options = Map { }; + $options = Map {}; foreach ($target['runtimes'] as $runtime) { $options[$runtime['name']] = batch_get_single_run($target, $runtime, $argv); @@ -166,7 +165,7 @@ function batch_get_all_runs( Vector $targets, Vector $argv, ): Map> { - $options = Map { }; + $options = Map {}; foreach ($targets as $target) { $options[$target['name']] = batch_get_all_runs_for_target($target, $argv); @@ -180,9 +179,9 @@ function batch_main(Vector $argv): void { $targets = batch_get_targets($json_config); $all_runs = batch_get_all_runs($targets, $argv); - $results = Map { }; + $results = Map {}; foreach ($all_runs as $target => $target_runs) { - $results[$target] = Map { }; + $results[$target] = Map {}; foreach ($target_runs as $engine => $run) { $results[$target][$engine] = PerfRunner::RunWithOptions($run); Process::cleanupAll(); @@ -191,8 +190,8 @@ function batch_main(Vector $argv): void { sleep(5); } } - print(json_encode($results, JSON_PRETTY_PRINT)."\n"); + print (json_encode($results, JSON_PRETTY_PRINT)."\n"); } -require_once('base/cli-init.php'); +require_once ('base/cli-init.php'); batch_main(new Vector($argv)); diff --git a/perf.php b/perf.php index 351ed4e..df65df1 100644 --- a/perf.php +++ b/perf.php @@ -9,7 +9,7 @@ * */ -require_once('base/cli-init.php'); +require_once ('base/cli-init.php'); function perf_main(Vector $argv): void { $data = PerfRunner::RunWithArgv($argv); diff --git a/targets/codeigniter/CodeIgniterTarget.php b/targets/codeigniter/CodeIgniterTarget.php index 70219df..8be80cd 100644 --- a/targets/codeigniter/CodeIgniterTarget.php +++ b/targets/codeigniter/CodeIgniterTarget.php @@ -10,10 +10,7 @@ */ final class CodeIgniterTarget extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} protected function getSanityCheckString(): string { return @@ -24,17 +21,19 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { - shell_exec($this->safeCommand(Vector { - 'tar', - '-C', $this->options->tempDir, - '-zxf', - __DIR__.'/CodeIgniter-2.2.0.tar.gz' - })); + shell_exec( + $this->safeCommand( + Vector { + 'tar', + '-C', + $this->options->tempDir, + '-zxf', + __DIR__.'/CodeIgniter-2.2.0.tar.gz', + }, + ), + ); } $index_path = $this->options->tempDir.'/CodeIgniter-2.2.0/index.php'; diff --git a/targets/drupal7/Drupal7Target.php b/targets/drupal7/Drupal7Target.php index 7f830d9..eb2ccba 100644 --- a/targets/drupal7/Drupal7Target.php +++ b/targets/drupal7/Drupal7Target.php @@ -10,10 +10,7 @@ */ final class Drupal7Target extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} protected function getSanityCheckString(): string { return 'Read more'; @@ -22,10 +19,7 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { Utils::ExtractTar( __DIR__.'/drupal-7.31.tar.gz', diff --git a/targets/drupal8/Drupal8Target.php b/targets/drupal8/Drupal8Target.php index 98af6c3..8f45940 100644 --- a/targets/drupal8/Drupal8Target.php +++ b/targets/drupal8/Drupal8Target.php @@ -10,10 +10,7 @@ */ abstract class Drupal8Target extends PerfTarget { - public function __construct( - protected PerfOptions $options, - ) { - } + public function __construct(protected PerfOptions $options) {} protected function getSanityCheckString(): string { return 'Read more'; @@ -22,10 +19,7 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { # Extract Drupal core. Utils::ExtractTar( @@ -48,9 +42,18 @@ public function install(): void { ); } # Settings files and our Twig template setup script. - copy(__DIR__.'/settings/settings.php', $this->getSourceRoot().'/sites/default/settings.php'); - copy(__DIR__.'/settings/setup.php', $this->getSourceRoot().'/sites/default/setup.php'); - copy(__DIR__.'/settings/services.yml', $this->getSourceRoot().'/sites/default/services.yml'); + copy( + __DIR__.'/settings/settings.php', + $this->getSourceRoot().'/sites/default/settings.php', + ); + copy( + __DIR__.'/settings/setup.php', + $this->getSourceRoot().'/sites/default/setup.php', + ); + copy( + __DIR__.'/settings/services.yml', + $this->getSourceRoot().'/sites/default/services.yml', + ); # Installing the database is left to the child targets. } @@ -66,14 +69,18 @@ public function drushPrep(): void { if ($hhvm) { putenv("DRUSH_PHP=$hhvm"); } - $drush = $this->options->tempDir . '/drush/drush'; + $drush = $this->options->tempDir.'/drush/drush'; $current = getcwd(); chdir($this->getSourceRoot()); // Rebuild Drupal's cache to clear out stale filesystem entries. shell_exec($drush.' cr'); // Try to pre-generate all Twig templates. - shell_exec('find . -name *.html.twig | '.$drush.' scr sites/default/setup.php 2>&1'); + shell_exec( + 'find . -name *.html.twig | '. + $drush. + ' scr sites/default/setup.php 2>&1', + ); chdir($current); } diff --git a/targets/laravel4/Laravel4Target.php b/targets/laravel4/Laravel4Target.php index d98a769..6cf8bea 100644 --- a/targets/laravel4/Laravel4Target.php +++ b/targets/laravel4/Laravel4Target.php @@ -10,10 +10,7 @@ */ final class Laravel4Target extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} protected function getSanityCheckString(): string { return 'You have arrived'; @@ -22,23 +19,30 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { - shell_exec($this->safeCommand(Vector { - 'tar', - '-C', $this->options->tempDir, - '-zxf', - __DIR__.'/laravel-4.2.0.tar.gz' - })); - shell_exec($this->safeCommand(Vector { - 'tar', - '-C', $this->options->tempDir.'/laravel-4.2.0', - '-jxf', - __DIR__.'/vendor.tar.bz2' - })); + shell_exec( + $this->safeCommand( + Vector { + 'tar', + '-C', + $this->options->tempDir, + '-zxf', + __DIR__.'/laravel-4.2.0.tar.gz', + }, + ), + ); + shell_exec( + $this->safeCommand( + Vector { + 'tar', + '-C', + $this->options->tempDir.'/laravel-4.2.0', + '-jxf', + __DIR__.'/vendor.tar.bz2', + }, + ), + ); } } diff --git a/targets/laravel5/Laravel5Target.php b/targets/laravel5/Laravel5Target.php index 4fe820a..2f2a742 100644 --- a/targets/laravel5/Laravel5Target.php +++ b/targets/laravel5/Laravel5Target.php @@ -10,10 +10,7 @@ */ final class Laravel5Target extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} protected function getSanityCheckString(): string { return 'Laravel 5'; @@ -22,23 +19,30 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { - shell_exec($this->safeCommand(Vector { - 'tar', - '-C', $this->options->tempDir, - '-zxf', - __DIR__.'/laravel-5.0.22.tar.gz' - })); - shell_exec($this->safeCommand(Vector { - 'tar', - '-C', $this->options->tempDir.'/laravel-5.0.22', - '-jxf', - __DIR__.'/vendor.tar.bz2' - })); + shell_exec( + $this->safeCommand( + Vector { + 'tar', + '-C', + $this->options->tempDir, + '-zxf', + __DIR__.'/laravel-5.0.22.tar.gz', + }, + ), + ); + shell_exec( + $this->safeCommand( + Vector { + 'tar', + '-C', + $this->options->tempDir.'/laravel-5.0.22', + '-jxf', + __DIR__.'/vendor.tar.bz2', + }, + ), + ); } } diff --git a/targets/magento1/Magento1Target.php b/targets/magento1/Magento1Target.php index 6cef811..1d21bea 100644 --- a/targets/magento1/Magento1Target.php +++ b/targets/magento1/Magento1Target.php @@ -12,15 +12,13 @@ final class Magento1Target extends PerfTarget { private DatabaseInstaller $installer; - public function __construct( - private PerfOptions $options - ) { + public function __construct(private PerfOptions $options) { $options->dumpIsCompressed = false; $this->installer = new DatabaseInstaller($this->options); $this->installer->setDatabaseName($this->getDatabaseName()); } - private function getDatabaseName() : string { + private function getDatabaseName(): string { return 'magento_bench'; } @@ -28,7 +26,8 @@ protected function getSanityCheckString(): string { return 'Madison Island'; } - private function getMagentoInstaller() : Mage_Install_Model_Installer_Console { + private function getMagentoInstaller( + ): Mage_Install_Model_Installer_Console { require_once $this->getSourceRoot().'/app/Mage.php'; $app = Mage::app('default'); @@ -38,34 +37,40 @@ private function getMagentoInstaller() : Mage_Install_Model_Installer_Console { return $installer; } - private function setPermissions() : void { + private function setPermissions(): void { foreach (array('media', 'var') as $dir) { - shell_exec($this->safeCommand(Vector { - 'chmod', - '-R', - 'o+w', - $this->getSourceRoot().'/'.$dir - })); + shell_exec( + $this->safeCommand( + Vector {'chmod', '-R', 'o+w', $this->getSourceRoot().'/'.$dir}, + ), + ); } } - private function installSampleData() : bool { + private function installSampleData(): bool { Utils::ExtractTar( __DIR__.'/magento-sample-data-1.9.0.0.tar.gz', - $this->options->tempDir + $this->options->tempDir, ); foreach (array('skin', 'media') as $type) { - shell_exec(implode(' ', array( - 'cp', - '-Rf', $this->getSampleDataDirectory().'/'.$type.'/*', - $this->getSourceRoot().'/'.$type - ))); + shell_exec( + implode( + ' ', + array( + 'cp', + '-Rf', + $this->getSampleDataDirectory().'/'.$type.'/*', + $this->getSourceRoot().'/'.$type, + ), + ), + ); } - $created_database = $this->installer - ->setDumpFile($this->getSampleDataDirectory().'/magento_sample_data_for_1.9.0.0.sql') - ->installDatabase(); + $created_database = $this->installer->setDumpFile( + $this->getSampleDataDirectory(). + '/magento_sample_data_for_1.9.0.0.sql', + )->installDatabase(); if (!$created_database) { return false; } @@ -73,17 +78,14 @@ private function installSampleData() : bool { } <<__Memoize>> - private function getSampleDataDirectory() : string { + private function getSampleDataDirectory(): string { return $this->options->tempDir.'/magento-sample-data-1.9.0.0'; } public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { Utils::ExtractTar( __DIR__.'/magento-1.9.0.1.tar.gz', @@ -109,8 +111,11 @@ public function install(): void { $installer = $this->getMagentoInstaller(); $installer->install(); if ($installer->hasErrors()) { - throw new Exception(sprintf("Installation failed: %s\n", - implode(PHP_EOL, $installer->getErrors())) + throw new Exception( + sprintf( + "Installation failed: %s\n", + implode(PHP_EOL, $installer->getErrors()), + ), ); } exit(0); @@ -119,28 +124,28 @@ public function install(): void { pcntl_waitpid($child, $status); } - private function getInstallerArgs() : array { + private function getInstallerArgs(): array { $url = 'http://'.gethostname().':'.PerfSettings::HttpPort().'/'; return array( - 'db_host' => '127.0.0.1', - 'db_name' => $this->getDatabaseName(), - 'db_user' => $this->installer->getUsername(), - 'db_pass' => $this->installer->getPassword(), + 'db_host' => '127.0.0.1', + 'db_name' => $this->getDatabaseName(), + 'db_user' => $this->installer->getUsername(), + 'db_pass' => $this->installer->getPassword(), 'license_agreement_accepted' => 1, - 'locale' => 'en_US', - 'timezone' => 'UTC', - 'default_currency' => 'USD', - 'url' => $url, - 'use_rewrites' => 0, - 'use_secure' => 0, - 'secure_base_url' => $url, - 'use_secure_admin' => 0, - 'admin_firstname' => 'Bench', - 'admin_lastname' => 'Mark', - 'admin_email' => 'bench@mark.com', - 'admin_username' => 'benchmark', - 'admin_password' => 'p@ssw0rd', - 'skip_url_validation' => 1 + 'locale' => 'en_US', + 'timezone' => 'UTC', + 'default_currency' => 'USD', + 'url' => $url, + 'use_rewrites' => 0, + 'use_secure' => 0, + 'secure_base_url' => $url, + 'use_secure_admin' => 0, + 'admin_firstname' => 'Bench', + 'admin_lastname' => 'Mark', + 'admin_email' => 'bench@mark.com', + 'admin_username' => 'benchmark', + 'admin_password' => 'p@ssw0rd', + 'skip_url_validation' => 1, ); } diff --git a/targets/mediawiki/MediaWikiTarget.php b/targets/mediawiki/MediaWikiTarget.php index 887cf91..7b7caf8 100644 --- a/targets/mediawiki/MediaWikiTarget.php +++ b/targets/mediawiki/MediaWikiTarget.php @@ -10,10 +10,7 @@ */ final class MediaWikiTarget extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} protected function getSanityCheckString(): string { return 'Obama'; @@ -22,10 +19,7 @@ protected function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { Utils::ExtractTar( __DIR__.'/mediawiki-1.24.0.tar.gz', @@ -45,7 +39,9 @@ public function install(): void { file_put_contents( $this->getSourceRoot().'/LocalSettings.php', - '$wgCacheDirectory="'.$cache_dir.'";'. + '$wgCacheDirectory="'. + $cache_dir. + '";'. // Default behavior is to do a MySQL query *for each translatable string // on every page view*. This is just insane. '$wgLocalisationCacheConf["store"] = "file";'. @@ -53,17 +49,19 @@ public function install(): void { // large-scale deployment should be using a more scalable solution such // as log files or Google Analytics '$wgDisableCounters = true;', - FILE_APPEND + FILE_APPEND, ); } <<__Override>> public function postInstall(): void { - Utils::RunCommand(Vector { - PHP_BINARY, - $this->getSourceRoot().'/maintenance/rebuildLocalisationCache.php', - '--lang=en', - }); + Utils::RunCommand( + Vector { + PHP_BINARY, + $this->getSourceRoot().'/maintenance/rebuildLocalisationCache.php', + '--lang=en', + }, + ); } public function getSourceRoot(): string { diff --git a/targets/sugarcrm/SugarCRMHomePageTarget.php b/targets/sugarcrm/SugarCRMHomePageTarget.php index 66dccea..fad36e2 100644 --- a/targets/sugarcrm/SugarCRMHomePageTarget.php +++ b/targets/sugarcrm/SugarCRMHomePageTarget.php @@ -21,17 +21,20 @@ protected function getSanityCheckString(): string { <<__Memoize>> public function getSiegeRCPath(): ?string { $path = tempnam($this->options->tempDir, 'siegerc'); - $query_data = implode('&', (Map { - 'module' => 'Users', - 'action' => 'Authenticate', - 'user_name' => 'admin', - 'user_password' => 'admin', - })->mapWithKey(($k, $v) ==> $k.'='.urlencode($v))); + $query_data = implode( + '&', + (Map { + 'module' => 'Users', + 'action' => 'Authenticate', + 'user_name' => 'admin', + 'user_password' => 'admin', + })->mapWithKey(($k, $v) ==> $k.'='.urlencode($v)), + ); $config = sprintf( "login-url = http://%s:%d/index.php POST %s\n", gethostname(), PerfSettings::HttpPort(), - $query_data + $query_data, ); file_put_contents($path, $config); return $path; diff --git a/targets/sugarcrm/SugarCRMTarget.php b/targets/sugarcrm/SugarCRMTarget.php index 047a533..4cf1959 100644 --- a/targets/sugarcrm/SugarCRMTarget.php +++ b/targets/sugarcrm/SugarCRMTarget.php @@ -10,27 +10,18 @@ */ abstract class SugarCRMTarget extends PerfTarget { - public function __construct( - protected PerfOptions $options, - ) { - } + public function __construct(protected PerfOptions $options) {} public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { $pd = new PharData(__DIR__.'/SugarCE-6.5.20.zip'); $pd->extractTo($this->options->tempDir); } - copy( - __DIR__.'/config.php', - $this->getSourceRoot().'/config.php', - ); + copy(__DIR__.'/config.php', $this->getSourceRoot().'/config.php'); if ($this->options->skipDatabaseInstall) { return; diff --git a/targets/wordpress/WordpressTarget.php b/targets/wordpress/WordpressTarget.php index 9fc2c06..20df7ae 100644 --- a/targets/wordpress/WordpressTarget.php +++ b/targets/wordpress/WordpressTarget.php @@ -11,10 +11,7 @@ final class WordpressTarget extends PerfTarget { - public function __construct( - private PerfOptions $options, - ) { - } + public function __construct(private PerfOptions $options) {} public function getSanityCheckString(): string { return 'Recent Comments'; @@ -23,10 +20,7 @@ public function getSanityCheckString(): string { public function install(): void { $src_dir = $this->options->srcDir; if ($src_dir) { - Utils::CopyDirContents( - $src_dir, - $this->getSourceRoot(), - ); + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); } else { Utils::ExtractTar( __DIR__.'/wordpress-4.2.0.tar.gz', @@ -34,31 +28,32 @@ public function install(): void { ); } - copy( - __DIR__.'/wp-config.php', - $this->getSourceRoot().'/wp-config.php', - ); + copy(__DIR__.'/wp-config.php', $this->getSourceRoot().'/wp-config.php'); - $created_database = (new DatabaseInstaller($this->options)) - ->setDatabaseName('wp_bench') - ->setDumpFile(__DIR__.'/dbdump.sql.gz') - ->installDatabase(); + $created_database = + (new DatabaseInstaller($this->options)) + ->setDatabaseName('wp_bench') + ->setDumpFile(__DIR__.'/dbdump.sql.gz') + ->installDatabase(); if (!$created_database) { return; } - $visible_port = $this->options->proxygen - ? PerfSettings::BackendPort() - : PerfSettings::HttpPort(); + $visible_port = + $this->options->proxygen + ? PerfSettings::BackendPort() + : PerfSettings::HttpPort(); $root = 'http://'.gethostname().':'.$visible_port; $conn = mysql_connect('127.0.0.1', 'wp_bench', 'wp_bench'); $db_selected = mysql_select_db('wp_bench', $conn); $result = mysql_query( 'UPDATE wp_options '. - "SET option_value='".mysql_real_escape_string($root)."' ". + "SET option_value='". + mysql_real_escape_string($root). + "' ". 'WHERE option_name IN ("siteurl", "home")', - $conn + $conn, ); if ($result !== true) { throw new Exception(mysql_error()); @@ -100,15 +95,16 @@ public function unfreeze(PerfOptions $options): void { private function unfreezeRequest(PerfOptions $options): void { $url = 'http://'.gethostname().':'.PerfSettings::HttpPort().'/'; $ctx = stream_context_create( - ['http' => ['timeout' => $options->maxdelayUnfreeze]] - ); - $data = file_get_contents( - $url, - /* include path = */ false, - $ctx, + ['http' => ['timeout' => $options->maxdelayUnfreeze]], ); + $data = file_get_contents($url, /* include path = */ false, $ctx); invariant( $data !== false, - 'Failed to unfreeze '.$url.' after '.$options->maxdelayUnfreeze.' secs'); + 'Failed to unfreeze '. + $url. + ' after '. + $options->maxdelayUnfreeze. + ' secs', + ); } }