-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add benchmarks for creating Strings from ASCII #27665
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
Add benchmarks for creating Strings from ASCII #27665
Conversation
@swift-ci please smoke benchmark |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibs
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I had two comments, but given the existing benchmarks, it may be best to ignore them. (Local consistency may be more valuable than global in this case.)
public func run_UTF8Decode_InitFromData_ascii_as_ascii(_ N: Int) { | ||
let input = asciiData | ||
for _ in 0..<1_000*N { | ||
blackHole(String(data: input, encoding: .ascii)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input
stays constant over the duration of the for statement, so I wonder if a sufficiently clever optimizer would be able to move some of its processing outside the loop.
It may be worth passing input
through identity
. (Then again, the other benchmarks don't do this, and we should stay consistent if we want to be able to compare results,)
@@ -42,6 +42,18 @@ public let UTF8Decode = [ | |||
name: "UTF8Decode_InitFromBytes_ascii", | |||
runFunction: run_UTF8Decode_InitFromBytes_ascii, | |||
tags: [.validation, .api, .String]), | |||
BenchmarkInfo( | |||
name: "UTF8Decode_InitFromData_ascii_as_ascii", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the names aren't great here. Shouldn't we call this ASCIIDecode.initFromData
?
The existing benchmarks have set an unfortunate pattern, but perhaps it's worth breaking it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt keeping the prefix the same was worthwhile for being able to do something like "run all the benchmarks for X". The name does really suck though.
No description provided.