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

optimize repeat(string, n) for repeating single ASCII chars #22462

Merged
merged 1 commit into from
Jun 24, 2017

Conversation

stevengj
Copy link
Member

While working on #22461, I noticed that nearly all uses of repeat(string,n) or string^n were for repeating strings consisting of a single ASCII character, most commonly " ". This PR speeds up that case by calling memset.

The speedups vary with length n. For n=5 I get a 50% speedup, for n=20 a 3.5x speedup, and for n=1000 I get a 41x speedup.

@stevengj stevengj added performance Must go faster strings "Strings!" labels Jun 21, 2017
@ararslan
Copy link
Member

Cool! Looks good to me. Looks like the Base string benchmarks won't really see this, so probably not worth running Nanosoldier.

@KristofferC KristofferC merged commit b1c2d73 into JuliaLang:master Jun 24, 2017
@tkelman tkelman added the potential benchmark Could make a good benchmark in BaseBenchmarks label Jun 24, 2017
DrTodd13 pushed a commit to IntelLabs/julia that referenced this pull request Jun 26, 2017
ararslan pushed a commit that referenced this pull request Sep 11, 2017
ararslan pushed a commit that referenced this pull request Sep 13, 2017
vtjnash pushed a commit that referenced this pull request Sep 14, 2017
ararslan pushed a commit that referenced this pull request Sep 15, 2017
@KristofferC KristofferC removed the potential benchmark Could make a good benchmark in BaseBenchmarks label Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants