-
Notifications
You must be signed in to change notification settings - Fork 10.5k
FlattenSequence/distance(from:to:) benchmarks. #71786
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
FlattenSequence/distance(from:to:) benchmarks. #71786
Conversation
@swift-ci please benchmark |
@swift-ci please smoke test |
let minor = repeatElement(00000, count: inner) | ||
let major = repeatElement(minor, count: outer) | ||
let flattened: FlattenSequence = major.joined() |
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.
These could be at the top level or, alternatively, in a setUpFunction
, so that creating them isn't part of the measurement.
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.
Are you sure you want to move these? It would be a lot of ceremony for 3
integers. Note that distance(from:to:)
is called 2 * outer^2 * inner^2 * iterations
times. I'm asking just in case you thought they were arrays.
▿ Swift.FlattenSequence<Swift.Repeated<Swift.Repeated<Swift.Int>>>
▿ _base: Swift.Repeated<Swift.Repeated<Swift.Int>>
- count: 32
▿ repeatedValue: Swift.Repeated<Swift.Int>
- count: 32
- repeatedValue: 0
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.
Nevermind. I found a solution I don't hate, then added a few sequential benchmarks for good measure. It's boilerplate-y but symmetrical. You could make it generic, but perhaps manual specialization is preferred in benchmarks?
@@ -89,6 +89,7 @@ import Exclusivity | |||
import ExistentialPerformance | |||
import Fibonacci | |||
import FindStringNaive | |||
import FlattenDistanceFromTo |
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.
Please also add register(FlattenDistanceFromTo.benchmarks)
at line 286 below.
With the PR as-is the benchmark runner still does not know about this addition.
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.
Sure. The script could use some love too:
The script will automatically:
- Edit main.swift by importing and registering* your new Swift module.
*The
cakeauto-registration is a lie.
1. Registered the new benchmarks in benchmark/utils/main.swift.
1. Parameterized benchmark dependencies, per code review.
1. Added some sequential tests with String as the inner collection.
I've updated the PR and added a few string-based tests. Here's some results using XCTest:
Swift 5.9
After (#71648)
So if these tests do not "run in a few milliseconds for N = 1", they might after applying the patch. |
1. Replaced occurrences of Repeated<T> with Array<T>.
I suppose you may write a better algorithm if all inner collections have the same number of elements, so I replaced occurrences of |
@swift-ci please benchmark |
1. The auto-generated [BenchmarkInfo] was given the wrong name.
I looked at the logs and saw that the auto-generated [BenchmarkInfo] was given the wrong name. I have changed the name in the most recent commit.
|
@swift-ci please benchmark |
|
It looks like they'd still be a bit long-running even after the performance improvement. |
The benchmarks took too long to perform, so I reduced the size of each payload.
I have cut the payload dimensions into halves and quarters in the most recent commit. |
This commit addresses some trials and tribulations I encountered while working on (swiftlang#71786). It: 1. fixes the auto-registration regex 2. fixes the auto-generated array's name 3. generates the current year for the license header 4. generates some dashes for the license header
@swift-ci please benchmark |
✅ | Benchmark Check Report |
Two mysterious issues remaining in the benchmarks:
|
@swift-ci please smoke test |
This commit addresses some trials and tribulations I encountered while working on (swiftlang#71786). It: 1. fixes the auto-registration regex 2. fixes the auto-generated array's name 3. generates the current year for the license header 4. generates some dashes for the license header
I wrote some benchmarks for (#71648). I'm new to
/benchmark
, but I read the README and ran the script.