Skip to content

Commit

Permalink
Align the peformance tests with the recent API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yanivmo committed Jun 7, 2017
1 parent c23d19f commit 7de64f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ True

Performance
===========
The performance is measured by comparing the matching time with the standard re library.
Currently ruler measures approximately 8 times slower than re.
The performance is measured by comparing the matching time with the standard ``re`` library.
Currently ruler measures approximately ten times slower than ``re``.


Development
Expand Down
5 changes: 2 additions & 3 deletions performance/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ class Morning(ruler.Grammar):
milk = ruler.Optional(' with milk')
tea = ruler.Rule('tea', milk)
what = ruler.OneOf(juice, tea)

_grammar_ = ruler.Rule(who, ' likes to drink ', what, '\.')
grammar = ruler.Rule(who, ' likes to drink ', what, '\.')


def one_match():
morning_rule = Morning()
morning_rule = Morning.create()
assert morning_rule.match('Ann likes to drink tea with milk.')
assert morning_rule.what.tea.milk.matched

Expand Down
5 changes: 2 additions & 3 deletions performance/re_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ class MorningDrink(r.Grammar):
milk = r.Rule('milk')
tea = r.Rule('tea', r.Optional(' with ', milk))
what = r.OneOf(juice, tea)
grammar = r.Rule(who, ' likes to drink ', what)

_grammar_ = r.Rule(who, ' likes to drink ', what)

self.grammar = MorningDrink()
self.grammar = MorningDrink.create()

self.timer = timeit.Timer('self.match()', globals=locals())

Expand Down

0 comments on commit 7de64f2

Please sign in to comment.