bug73837.phpt makes no sense
Description
Hi. I try to build php engine from source code and I've got an error Bug #73837: Milliseconds in DateTime() [ext/date/tests/bug73837.phpt] The problem is here
The following code:
Bug #73837: Milliseconds in DateTime()
--FILE--
<?php
$collect = [];
for ( $i = 0; $i < 1000; $i++ )
{
$a = new DateTime();
$key = "s" . $a->format( "u" );
$collect[$key] = true;
}
$status=array_count_values($collect);
var_dump($status);
var_dump($n = count( $collect ));
echo ( $n > 700 ) ? "microseconds differ\n" : "microseconds do not differ enough ($n)\n";
?>
--EXPECTF--
int(%d)
microseconds differ
Could anybody explain me the reason to make this test? What would we like to test here? I suppose, each block iteration by $i isn't equal one second, cause we are working in user space OS.
Solutions looks like PHP8.1 branch but I still wonder the test reason
--TEST--
Bug #73837: Milliseconds in DateTime()
--FILE--
<?php
$collect = [];
for ( $i = 0; $i < 1000; $i++ )
{
$a = new DateTime();
$key = "s" . $a->format( "u" );
$collect[$key] = true;
}
// For low-resolution clocks, we may construct many objects in the same tick.
var_dump($n = count( $collect ));
echo $n > 200 ? "microseconds differ\n" : "microseconds do not differ enough ($n)\n";
?>
--EXPECTF--
int(%d)
microseconds differ
build params ./configure' '--build=x86_64' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--disable-all' '--with-pic' '--with-password-argon2' '--with-zlib' '--enable-xml' '--with-libxml' '--disable-phpdbg' '--with-pear' '--disable-cgi' '--enable-fpm' '--with-fpm-user=www-data' '--with-fpm-group=www-data' 'build_alias=x86_64'
PHP Version
PHP 7.4.29
Operating System
REHL
PHP Version
PHP 7.4.29
Operating System
REHL
As the title of the test indicates, it is supposed to be a regression test for bug 73837. I have to admit that I do not see that it is a sensible regression test for that issue, though.
@derickr, can you please check that test case?