Sitelet https://web.archive.org/web/20200904212641/https://github.com/phpbench/phpbench/pull/656/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion Refactoring: Use DSL and allow assertions on baseline #656

Merged
merged 30 commits into from Aug 30, 2020

Conversation

@dantleech
Copy link
Member

dantleech commented Aug 28, 2020 •

This PR refactores the assertion feature:

  • Use a DSL e.g. @Assert("variant.mean < 100 microseconds +/- 10 microseconds")
  • Allow assertion against baseline if set: @Assert("variant.mode < baseline.mode +/- 10 milliseconds")

The DSL is using the Parsica library which requires PHP 7.4 - need to decide if we bump the whole library to 7.4 or backport some or all of Parsica to 7.2/7.3.

Features:

  • @Assert("variant.mode within 10% +/- 5% of baseline.mode)#
  • phpbench run benchmarks/MyBench.php --assert="variant.mode < 5 microseconds"

TODO:

  • Support all comparison operators
  • Format time units in assertions (e.g. microseconds => μs, +/- => ±)
  • Format perentage values
  • Support tolerance with comparisons
  • Support logical AND//OR (?)
  • Support throughput assertions (e.g. @Assert("variant.mode throughput > 100 rps) ??)
  • Check % cases (e.g. working with tolerance)
  • Remove WITHIN operator
  • Remove warnings?
lib/Math/Distribution.php Outdated Show resolved Hide resolved
@@ -110,7 +112,7 @@ public function testLogError()
{
$this->variant->hasErrorStack()->willReturn(true);
$this->variant->getSubject()->willReturn($this->subject->reveal());
$this->variant->hasFailed()->willReturn(false);
$this->variant->getAssertionResults()->willReturn(new VariantAssertionResults($this->variant->reveal(), []));

This comment has been minimized.

@dantleech

dantleech Aug 28, 2020

Author Member

Should really refactor so that these mocks can be removed.

@dantleech dantleech force-pushed the assertion-dsl branch from b98fa73 to bf35e15 Aug 30, 2020
dantleech added 3 commits Aug 30, 2020
@dantleech dantleech merged commit 96f1abc into master Aug 30, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@dantleech dantleech deleted the assertion-dsl branch Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.