-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
--TEST-- | ||
Bug #73837: Milliseconds in DateTime() | ||
--SKIPIF-- | ||
<?php | ||
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); | ||
?> | ||
--FILE-- | ||
<?php | ||
$collect = []; | ||
|
||
for ( $i = 0; $i < 1000; $i++ ) | ||
{ | ||
$a = new DateTime(); | ||
$key = "s" . $a->format( "u" ); | ||
$collect[$key] = true; | ||
$startTS = time(); | ||
$prev_dt = new DateTime(); | ||
while (time() < $startTS + 2) { | ||
$dt = new DateTime(); | ||
if ($prev_dt > $dt) { | ||
var_dump($prev_dt->format("Y-m-d H:i:s.u")); | ||
var_dump($dt->format("Y-m-d H:i:s.u")); | ||
break; | ||
} | ||
$prev_dt = $dt; | ||
} | ||
|
||
// 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"; | ||
echo "Finished\n"; | ||
?> | ||
--EXPECTF-- | ||
int(%d) | ||
microseconds differ | ||
Finished |