Skip to content

Add more benchmarks and benchmarker functionality #505

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

Merged
merged 10 commits into from
Jun 21, 2022

Conversation

rctcwyvrn
Copy link
Contributor

@rctcwyvrn rctcwyvrn commented Jun 20, 2022

Adds debug mode (show matches/ # of matches), the ability to save/compare results, and benchmarks for email and html regexes

Is based on top of #501

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great so far!

A couple comments, but overall good direction

if let otherVal = other.results[item.key] {
let diff = item.value - otherVal
// note: is this enough time difference?
if diff.abs() > Time.millisecond {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't normalize our execution times, and some of them run in under a millisecond total. Should we be doing something relative?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we may want to remove this just for now and let the user decide. We're not doing long-term perf tracking with this (at least not yet), but it's very useful for development-cycle perf testing.

benchmark.addGraphemeBreak()
benchmark.addHangulSyllable()
benchmark.addHTML()
benchmark.addEmail()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way that the benchmarks can add themselves instead of having a second listing?

}

extension NSBenchmark {
public func debug() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the workflow look like for using this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the benchmarker normally blackholes the output of the regex it made it easy for regexes that had typos or mistakes in them to go unnoticed (like the css regex)

The debug mode just prints out the match that it found or the number of matches and that lets us make sure the the regexes are at least running somewhat correctly, for example by checking that the number of matches is the same across swift and ns regex

I was using it when adding the html and email regexes by just running something like ./RegexBenchmark --debug emailLookaheadFirst

let emailRFC = #"[A-z0-9!#$%&'*+\/=?^_‘{|}~-]+(?:\.[A-z0-9!#$%&'*+\/=?^_‘{|}~-]+)*@(?:[A-z0-9](?:[A-z0-9-]*[A-z0-9])?\.)+[A-z0-9](?:[A-z0-9-]*[A-z0-9])?"#

// More complex, does length and consecutive hyphen validation via lookaheads
let emailWithLookaheads = #"(?=[A-z0-9][A-z0-9@._%+-]{5,253})[A-z0-9._%+-]{1,64}@(?:(?=[A-z0-9-]{1,63}\.)[A-z0-9]+(?:-[A-z0-9]+)*\.){1,8}[A-z]{2,63}"#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat

@@ -0,0 +1,22 @@
import string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment with the command-line invocation to populate the output folder file.

@milseman
Copy link
Member

@swift-ci please test

@milseman milseman merged commit e0af639 into swiftlang:main Jun 21, 2022
@milseman
Copy link
Member

Merging to unblock some other perf work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants