From 9825e7121e48e52d966bcb6bfe4b11f29d92908c Mon Sep 17 00:00:00 2001 From: Andrew Klein Date: Tue, 31 Jan 2017 09:01:38 -0800 Subject: [PATCH 1/3] updating oss-performance to work with recent changes to invariant signature --- base/BuildChecker.php | 2 +- base/PerfRunner.php | 3 +++ base/PerfTarget.php | 1 + base/Siege.php | 2 +- targets/wordpress/WordpressTarget.php | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/base/BuildChecker.php b/base/BuildChecker.php index b0bd239..9278ebb 100644 --- a/base/BuildChecker.php +++ b/base/BuildChecker.php @@ -39,7 +39,7 @@ public static function Check( if ($skipKeys->contains($k)) { continue; } - invariant(is_array($v), $k.' is not an array'); + invariant(is_array($v), '%s', $k.' is not an array'); $v = self::MakeCheckedValue($v); if ($v['OK']) { continue; diff --git a/base/PerfRunner.php b/base/PerfRunner.php index 8b36580..c7d4298 100644 --- a/base/PerfRunner.php +++ b/base/PerfRunner.php @@ -84,6 +84,7 @@ private static function RunWithOptionsAndEngine( Process::sleepSeconds($options->delayPhpStartup); invariant( $php_engine->isRunning(), + '%s', 'Failed to start '.get_class($php_engine), ); @@ -114,6 +115,7 @@ private static function RunWithOptionsAndEngine( invariant(!$siege->isRunning(), 'Siege is still running :/'); invariant( $php_engine->isRunning(), + '%s', get_class($php_engine).' crashed', ); } else { @@ -130,6 +132,7 @@ private static function RunWithOptionsAndEngine( invariant(!$siege->isRunning(), 'Siege is still running :/'); invariant( $php_engine->isRunning(), + '%s', get_class($php_engine).' crashed', ); } else { diff --git a/base/PerfTarget.php b/base/PerfTarget.php index 1ce9b2d..edcf072 100644 --- a/base/PerfTarget.php +++ b/base/PerfTarget.php @@ -30,6 +30,7 @@ final public function sanityCheck(): void { $content = file_get_contents($url, /* include path = */ false, $ctx); invariant( strstr($content, $this->getSanityCheckString()) !== false, + '%s', 'Failed to find string "'.$this->getSanityCheckString().'" in '.$url, ); } diff --git a/base/Siege.php b/base/Siege.php index 0cc1922..e7e9131 100644 --- a/base/Siege.php +++ b/base/Siege.php @@ -146,7 +146,7 @@ protected function getArguments(): Vector { return $arguments; default: invariant_violation( - 'Unexpected request mode: '.(string) $this->mode, + '%s', 'Unexpected request mode: '.(string) $this->mode, ); } } diff --git a/targets/wordpress/WordpressTarget.php b/targets/wordpress/WordpressTarget.php index 20df7ae..8459f5a 100644 --- a/targets/wordpress/WordpressTarget.php +++ b/targets/wordpress/WordpressTarget.php @@ -100,6 +100,7 @@ private function unfreezeRequest(PerfOptions $options): void { $data = file_get_contents($url, /* include path = */ false, $ctx); invariant( $data !== false, + '%s', 'Failed to unfreeze '. $url. ' after '. From 868fd5bbd23e67d580814c6d5b43456cd8c01294 Mon Sep 17 00:00:00 2001 From: Andrew Klein Date: Tue, 31 Jan 2017 09:34:26 -0800 Subject: [PATCH 2/3] updating change to reflect comments --- base/BuildChecker.php | 2 +- base/PerfRunner.php | 12 ++++++------ base/PerfTarget.php | 5 +++-- base/Siege.php | 2 +- targets/wordpress/WordpressTarget.php | 9 +++------ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/base/BuildChecker.php b/base/BuildChecker.php index 9278ebb..31103b9 100644 --- a/base/BuildChecker.php +++ b/base/BuildChecker.php @@ -39,7 +39,7 @@ public static function Check( if ($skipKeys->contains($k)) { continue; } - invariant(is_array($v), '%s', $k.' is not an array'); + invariant(is_array($v), '%s is not an array', $k); $v = self::MakeCheckedValue($v); if ($v['OK']) { continue; diff --git a/base/PerfRunner.php b/base/PerfRunner.php index c7d4298..1aed7ba 100644 --- a/base/PerfRunner.php +++ b/base/PerfRunner.php @@ -84,8 +84,8 @@ private static function RunWithOptionsAndEngine( Process::sleepSeconds($options->delayPhpStartup); invariant( $php_engine->isRunning(), - '%s', - 'Failed to start '.get_class($php_engine), + 'Failed to start %s', + get_class($php_engine), ); if ($target->needsUnfreeze()) { @@ -115,8 +115,8 @@ private static function RunWithOptionsAndEngine( invariant(!$siege->isRunning(), 'Siege is still running :/'); invariant( $php_engine->isRunning(), - '%s', - get_class($php_engine).' crashed', + '%s crashed', + get_class($php_engine), ); } else { self::PrintProgress('Skipping single request warmup'); @@ -132,8 +132,8 @@ private static function RunWithOptionsAndEngine( invariant(!$siege->isRunning(), 'Siege is still running :/'); invariant( $php_engine->isRunning(), - '%s', - get_class($php_engine).' crashed', + '%s crashed', + get_class($php_engine), ); } else { self::PrintProgress('Skipping multi request warmup'); diff --git a/base/PerfTarget.php b/base/PerfTarget.php index edcf072..982a080 100644 --- a/base/PerfTarget.php +++ b/base/PerfTarget.php @@ -30,8 +30,9 @@ final public function sanityCheck(): void { $content = file_get_contents($url, /* include path = */ false, $ctx); invariant( strstr($content, $this->getSanityCheckString()) !== false, - '%s', - 'Failed to find string "'.$this->getSanityCheckString().'" in '.$url, + 'Failed to find string "%s" in %s', + $this->getSanityCheckString(), + $url, ); } diff --git a/base/Siege.php b/base/Siege.php index e7e9131..3859af1 100644 --- a/base/Siege.php +++ b/base/Siege.php @@ -146,7 +146,7 @@ protected function getArguments(): Vector { return $arguments; default: invariant_violation( - '%s', 'Unexpected request mode: '.(string) $this->mode, + 'Unexpected request mode: %s', (string) $this->mode, ); } } diff --git a/targets/wordpress/WordpressTarget.php b/targets/wordpress/WordpressTarget.php index 8459f5a..5f11a47 100644 --- a/targets/wordpress/WordpressTarget.php +++ b/targets/wordpress/WordpressTarget.php @@ -100,12 +100,9 @@ private function unfreezeRequest(PerfOptions $options): void { $data = file_get_contents($url, /* include path = */ false, $ctx); invariant( $data !== false, - '%s', - 'Failed to unfreeze '. - $url. - ' after '. - $options->maxdelayUnfreeze. - ' secs', + 'Failed to unfreeze %s after %s secs', + $url, + $options->maxdelayUnfreeze, ); } } From 4c43880f0e0981c4d3830ba5f0595faa82fa374c Mon Sep 17 00:00:00 2001 From: Andrew Klein Date: Tue, 31 Jan 2017 12:01:26 -0800 Subject: [PATCH 3/3] changing %s to %f for a numeric value --- targets/wordpress/WordpressTarget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/wordpress/WordpressTarget.php b/targets/wordpress/WordpressTarget.php index 5f11a47..f773235 100644 --- a/targets/wordpress/WordpressTarget.php +++ b/targets/wordpress/WordpressTarget.php @@ -100,7 +100,7 @@ private function unfreezeRequest(PerfOptions $options): void { $data = file_get_contents($url, /* include path = */ false, $ctx); invariant( $data !== false, - 'Failed to unfreeze %s after %s secs', + 'Failed to unfreeze %s after %f secs', $url, $options->maxdelayUnfreeze, );