Skip to content

Commit

Permalink
MicrotimeRepresentationTest: Memory is more accurate since 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Nov 10, 2023
1 parent 9399415 commit e67e37f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/Zval/Representation/MicrotimeRepresentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public function testConstruct()
{
$r = new MicrotimeRepresentation(123, 456, 7, 8, 100);

$mem = \memory_get_usage();
$mem_peak = \memory_get_peak_usage();

$this->assertSame(123, $r->seconds);
$this->assertSame(456, $r->microseconds);
$this->assertSame(7, $r->group);
Expand All @@ -57,10 +54,9 @@ public function testConstruct()
$this->assertSame(5, $r->i);
$this->assertSame(20.0, $r->avg);

// PHP 5.3 needs a leeway of 3k, 5.4+ needs 2k.
// At some point in the 7.x range they become exactly equal.
$this->assertLessThan(3000, \abs($mem - $r->mem));
$this->assertSame($mem_peak, $r->mem_peak);
// Memory usage isn't going to be identical after making the representation
$this->assertLessThan(1024, \abs(\memory_get_usage() - $r->mem));
$this->assertSame(\memory_get_peak_usage(), $r->mem_peak);
}

/**
Expand Down

0 comments on commit e67e37f

Please sign in to comment.