From 0fe04c560fdecec354f0498ead02176e341edc99 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Tue, 27 Oct 2020 16:19:58 +0100 Subject: [PATCH 1/2] constant size for bench.php i don't like the previous behaviour where the bytes to hash change every time the code change, that may make it difficult to compare hash() performance changes over time, as a recent example, Nikita's commit from 2020-10-26 changed the bytes to hash from 2240 bytes to 503 bytes.. ( e0ea3e8a0180ec86e3c5da80e4a0bf5b12dea84d ) --- ext/hash/bench.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/hash/bench.php b/ext/hash/bench.php index 7a0bc4ff54038..a9e08ede7735d 100755 --- a/ext/hash/bench.php +++ b/ext/hash/bench.php @@ -3,7 +3,8 @@ error_reporting(E_ALL); -$data = file_get_contents(__FILE__); +// 2240 comes from the fact that it used to be file_get_contents(__FILE__); +$data = str_repeat("\x00", 2240); $time = array(); foreach (hash_algos() as $algo) { $time[$algo] = 0; From e213df9934c5242c24b704e058fc31f755957fee Mon Sep 17 00:00:00 2001 From: divinity76 Date: Wed, 28 Oct 2020 18:42:29 +0100 Subject: [PATCH 2/2] nice round number + argv[1] quote: @nikic I don't think there's any point in preserving the exact previous size. Let's make this a nice round number like 2048. Could also make it $argv[1] ?? 2048 to allow passing a different size :) --- ext/hash/bench.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/hash/bench.php b/ext/hash/bench.php index a9e08ede7735d..846163315b86c 100755 --- a/ext/hash/bench.php +++ b/ext/hash/bench.php @@ -3,8 +3,7 @@ error_reporting(E_ALL); -// 2240 comes from the fact that it used to be file_get_contents(__FILE__); -$data = str_repeat("\x00", 2240); +$data = str_repeat("\x00", (int) ($argv[1] ?? (2 * 1024))); $time = array(); foreach (hash_algos() as $algo) { $time[$algo] = 0;