-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Implement a custom Data.Iterator #3831
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
Conversation
ptr[i] = UInt8(i % 23) | ||
} | ||
} | ||
checkSequence(data, (0..<65535).lazy.map({ UInt8($0 % 23) })) |
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 use two spaces for indentation unless the file already uses 4.
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.
Done.
@swift-ci Please test |
LGTM, but deferring to @parkera to approve once CI passes. |
ptr[i] = UInt8(i % 23) | ||
} | ||
} | ||
checkSequence(data, (0..<65535).lazy.map({ UInt8($0 % 23) })) |
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.
One more thing: the expected value is the first parameter, sequence under test is the second.
public func checkSequence<
${genericParam}, S : Sequence
>(
_ expected: ${Expected},
_ sequence: S,
We should probably add argument labels to this function.
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.
Oops. That's a pretty important distinction.
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.
Done.
Great idea, thanks @kballard . |
This iterator uses an inline 32-byte buffer so it doesn't have to call copyBytes(to:count:) for every single byte. It results in an approximate 6x speedup on my computer.
@swift-ci Please test |
Tests passed, CI failed for other reasons. |
Reverted in #3848:
|
D'oh. Why didn't that fail with my local build? |
@kballard Because we just changed what |
Re-submitted as #3849. |
What's in this pull request?
Implement a custom
Data.Iterator
instead of using the defaultIndexingIterator
. This custom iterator uses an internal 32-byte buffer so it doesn't have to callcopyBytes(to:count:)
as often. This results in an approximate 6x speedup on my computer.With the included benchmark, I get the following numbers with
IndexingIterator
:And the following numbers with the custom iterator:
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.