]> granicus.if.org Git - php/commitdiff
Use constant size string in hash bench.php
authordivinity76 <divinity76@gmail.com>
Tue, 27 Oct 2020 15:19:58 +0000 (16:19 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Oct 2020 08:54:48 +0000 (09:54 +0100)
I don't like the previous behaviour where the bytes to hash change
every time the code changes, that may make it difficult to compare
hash() performance changes over time.

Use a fixed number instead, and allow passing an override for a
different length.

Closes GH-6386.

[ci skip]

ext/hash/bench.php

index 7a0bc4ff54038ed26ffc64d1531f290f1b710c3f..846163315b86ca6c3b94cfaa2eec18f40dbe5aab 100755 (executable)
@@ -3,7 +3,7 @@
 
 error_reporting(E_ALL);
 
-$data = file_get_contents(__FILE__);
+$data = str_repeat("\x00", (int) ($argv[1] ?? (2 * 1024)));
 $time = array();
 foreach (hash_algos() as $algo) {
     $time[$algo] = 0;