* Add benchmarks for Substring.dropFirst(_:) and dropLast(_:)
These are self-slicing operations, so they should be fast even for
this non-random-access collection.
* Fiddle with the iteration count and length
I am going to be adding a variant of this that uses
Unmanaged._withUnsafeGuaranteedRef(...). To truly make it fair, I am
adding variants that also use an access ref entrypoint.
I am going to add a version of this that tests that Unmanaged._withUGR
gives us expected performance. So we really need both versions of all of
the four current benchmarks to make this truly fair.
This patch adds a benchmark to the Swift benchmark suite based on the
ChaCha20 encryption algorithm.
As Swift evolves it is important that it tackles more and more features
and possible use cases. One of these great use-cases is low-level CPU
intensive code, and cryptographic algorithms are a really important
test-bed.
This benchmark therefore provides a real-world test case for Swift's
optimiser. My ideal outcome here is that Swift should be able to perform
as well at this benchmark as a naive equivalent C implementation.
Global variables are being used as if they are "free black
holes". They might be even more expensive than actually calling
blackHole. But the right thing to do is use local variables and pass
them into a black hole at the end of computation.
Specifically, I add some benchmarks for weak, unowned, unsafe (unowned), and
unmanaged. The reason for the split in between unsafe (unowned) and unmanaged is
that one is testing the raw compiler features and the other is validating stdlib
performance.
This benchmark was "accidentally" accessing a global variable in the
main iteration loop, which is in some situations very expensive and
has nothing to do with what the benchmark is trying to test.
FindStringNaive is a simple benchmark which implements a naive String
finding algorithm that currently shows a lot of ARC traffic, hopefully
to be reduced in the future.
This currently copies the array each time it swaps elements. This
makes it 1500x slower than it should be to sort the array. The
benchmark now runs in 15ms but should be around 10us when fully
optimized.
This algorithm is an interesting optimization problem involving array
optimization, uniqueness, bounds checks, and exclusivity. But the
general first order problem is how to modify a CoW data structure
that's stored in a class property. As it stands, the property getter
retains the class property around the modify accesses that checks
uniqueness.