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

Make portRe constant #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

iustin24
Copy link

@iustin24 iustin24 commented Jun 5, 2022

When running unfurl format %r.%t on a long list of urls, the function extractFromDomain() will be called separately for each one of the urls, multiple times.
This causes the same regex to be compiled multiple times:

	portRe := regexp.MustCompile(`(?m):\d+$`)

Instead, portRe should be a constant. I changed the regexp to be constant and tested it on a list of 1.1 Million urls. I got the following results:

Old: 0m35.384s
New: 0m21.374s

When running `unfurl format %r.%t` on a long list of urls, the function `extractFromDomain()` will be called separately for each one of the urls, multiple times. 
This causes the same regex to be compiled multiple times:
```
	portRe := regexp.MustCompile(`(?m):\d+$`)
```

Instead, portRe should be a constant. I changed the regexp to be constant and tested it on a list of 1.1 Million urls. I got the following results:

Old: 0m35.384s
New: 0m21.374s
@iustin24
Copy link
Author

Hi @tomnomnom,

Did you have the time to review this?

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.

3 participants