Commit Graph

57 Commits

Author SHA1 Message Date
Slava Pestov
48eddac961 Benchmarks: Add support for async benchmarks 2025-08-27 10:37:10 -04:00
Slava Pestov
2ec19ecb46 Benchmarks: Skip long benchmarks in -Onone build 2025-08-27 10:37:10 -04:00
Erik Eckstein
6ef5908bdc benchmarks: fix the Fibonacci and Ackermann benchmarks
The `getFalse` utility function was not excluded from cross-module-optimization, which led the optimizer to completely eliminate the main loop body
Also, the passed `N` was shadowed by a local `n`.
2022-10-19 18:09:24 +02:00
Alex Lorenz
e659a52f46 [interop] mark C++ benchmarks with cxxInterop tag for easy local testing 2022-10-03 17:13:10 -07:00
Josh Soref
fa3ff899a9 Spelling benchmark (#42457)
* spelling: approximate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: available

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: benchmarks

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: between

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: calculation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: characterization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: coefficient

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: computation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deterministic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: divisor

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: encounter

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: expected

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: fibonacci

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: fulfill

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: implements

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: into

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intrinsic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: markdown

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: measure

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurrences

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: omitted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: partition

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: performance

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: practice

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: preemptive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: repeated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: requirements

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: requires

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: response

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: supports

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unknown

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: utilities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: verbose

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-25 09:02:06 -07:00
Erik Eckstein
1fceeab71e benchmarks: prevent some functions from being cross-module optimized.
Function bodies of `blackHole`, `identity`, etc. must not be visible in the benchmark modules.
Enabling CMO by default broke this. Since then we need to explicitly exclude those functions from cross-module-optimization.
2022-04-19 13:59:56 +02:00
Karoy Lorentey
958733c812 [benchmark] False() → getFalse() 2021-09-15 22:08:07 -07:00
Karoy Lorentey
bd9a22099a [benchmark] Random(), SRand() → LFSR.init(), .next() 2021-09-15 22:08:07 -07:00
Karoy Lorentey
203dc55b60 [benchmark] CheckResults → check
Capitalizing function names is against Swift naming conventions.
2021-09-15 22:08:07 -07:00
Stephen Canon
13812776cc Some initial benchmarks for simd integer arithmetic. 2021-03-19 11:19:35 -04:00
Richard Wei
b8581cb83b [AutoDiff] Add differentiation benchmarks (#34901)
* Add differentiation benchmarks.
* Make install name of _Differentiation be @rpath/libswift_Differentiation.dylib.

Co-authored-by: Marc Rasi <marcrasi@google.com>
2020-12-02 12:26:31 -08:00
Micah Benn
71784065cb Add IndexPath benchmarks
Add benchmarks for subscripts, max, min
2020-11-01 08:39:51 -06:00
Andrew Trick
7e9b46ee03 Add SortArrayInClass benchmark.
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.
2019-08-15 16:32:37 -07:00
Pavol Vaskovic
5190db0acd [Gardening][benchmark] Import MSVCRT on Windows
Import functions from standard C library on Windows.
2019-07-01 16:11:55 +02:00
Pavol Vaskovic
ea80003b0c Merge pull request #24307 from palimondo/legacy-factor-doc
[benchmark] Documentation for legacyFactor
2019-04-29 08:02:53 +02:00
Pavol Vaskovic
d2a47db71a [benchmark] Add SplitMix64 PRNG
Very fast pseudorandom number generator with 64 bits of state, conforming to `RandomNumberGenerator` protocol, passing BigCrush.
2019-04-28 19:23:42 +02:00
Pavol Vaskovic
e779e06ba2 [benchmark] Documentation for legacyFactor 2019-04-28 18:23:01 +02:00
Pavol Vaskovic
7896909d23 [benchmark] Move fake autoreleasepool to TestUtils
This workaround for writing cross platform benchmarks is required in multiple performance tests.
2019-02-19 07:50:12 +01:00
Pavol Vaskovic
0ac591e27b [benchmark] Add .existential BenchmarkCategory 2019-02-06 12:38:50 +01:00
Maxim Moiseev
cbf83ac04f [NFC][stdlib] Add FIXME markers to simplify audit 2018-11-14 11:58:42 -08:00
Slava Pestov
f6c2caf64b stdlib: Add @inlinable to @inline(__always) declarations
These should be audited since some might not actually need to be
@inlinable, but for now:

- Anything public and @inline(__always) is now also @inlinable
- Anything @usableFromInline and @inline(__always) is now @inlinable
2018-11-13 15:15:07 -05:00
Pavol Vaskovic
a7f832fb57 [benchmark] Legacy factor
This adds optional `legacyFactor` to the `BenchmarkInfo`, which allows for linear modification of constants that unnecesarily inflate the base workload of benchmarks, while maintaining the continuity of log-term benchmark tracking.

For example, if a benchmark uses `for _ in N*10_000` in its run function, we could lower this to `for _ in N*1_000` and adding a `legacyFactor: 10` to its `BenchmarkInfo`.

Note that this doesn’t affect the real measurements gathered from the `--verbose` output. The `BenchmarkDoctor` has been slightly adjusted to work with these real samples, therefore `Benchmark_Driver check` will not flag these benchmarks for slow run time reported in the summary, if their real runtimes fall into the recommended range.
2018-11-01 06:24:27 +01:00
Erik Eckstein
bd43d54b99 benchmarks: Move the setup and teardown functions out of the sample loop.
This is important to minimize the runtime when many samples are taken.
2018-07-24 20:20:23 -07:00
Pavol Vaskovic
2d004970fd [benchmark] Fix: Running skip-tag-marked benchmark
Also updated benchmark documentation with more detailed description of tag handling.
2018-07-11 23:17:02 +02:00
Pavol Vaskovic
4c4c6a2409 [benchmark] Fix: Better tags in benchmark list
When listing benchmarks with `--list` parameter, present the tags in format that is actually accepted by the `--tags` and `--skip-tags` parameters.

Changes the `--list` output from
````
Enabled Tests,Tags
AngryPhonebook,[TestsUtils.BenchmarkCategory.validation, TestsUtils.BenchmarkCategory.api, TestsUtils.BenchmarkCategory.String]
...
````
into
````
Enabled Tests,Tags
AngryPhonebook,[String, api, validation]
…
````
2018-07-11 23:17:02 +02:00
Michael Gottesman
45b7743086 [benchmark] Add the ability for a benchmark to specify that it does not run on specific platforms.
Today, one can not completely disable a benchmark depending on the platform
without changing the source of main.swift. We would like to be able to disable
benchmarks locally in a benchmark's file without needing to modify the rest of
the infrastructure. The closest that one can get to such behavior is to just
conditionally compile out the file locally. But one still will have the test
run.

This commit adds support for not-running the benchmark on specific
platforms. This in combination with conditional compilation of benchmark bodies,
allows us to not have to comment out module's in main.swift or have to
conditionally compile testinfo.

rdar://40541972
2018-05-28 18:12:58 -07:00
Michael Ilseman
5bb2e62280 [benchmark] ArrayAppend for substrings.
Add substring-view-oriented array append benchmarks. Put a
getString/getSubstring call into the innermost loop to prevent some
constant folding towards triviality.
2018-04-30 14:01:51 -07:00
Karoy Lorentey
ec91f6b6d6 [benchmark] Replace hashValue implementations with hash(into:)
This gives us a better picture of expected hashing performance.

Add a new benchmark to track legacy hashValue performance.
2018-04-25 19:17:16 +01:00
Tony Parker
19c6ccf5af Updated Data benchmarks 2018-03-13 17:29:50 -07:00
Ben Cohen
1e820dc505 Add benchmarks based on different remove(where:) implementations 2018-02-15 16:03:38 -08:00
Karoy Lorentey
c6a4d1131e Make sure string benchmarks actually measure string operations
The optimizer was sometimes able to eliminate most/all of the actual operations, so some benchmarks were not really measuring anything.
2017-11-08 19:15:47 +00:00
Erik Eckstein
46c96978b3 benchmarks: remove deprecated CheckResults function 2017-10-09 16:33:34 -07:00
Max Moiseev
c35cd06c70 Fix a typo 2017-10-04 12:24:21 -07:00
Max Moiseev
86eeb5416b Introduce .skip tag and properly handle --skip-tags parameter 2017-10-03 10:07:50 -07:00
Michael Gottesman
f7681a993a [benchmark] Add support for specifying a benchmark setUp and tearDown function via BenchmarkInfo.
The key thing here is that by providing one of these closures, a benchmark can
inject the initialization/deinitialization of its internal data structures,
outside of the time period where timing is occurring.

The intention is that this will provide us the framework for as we annotate
tests with BenchmarkInfo, to move initialization work out of benchmarks.

It will also allow for more complex benchmarks to be written such as ones that
perform bulk reads from a pipe (my interest in this).
2017-09-28 09:57:46 -07:00
Michael Gottesman
8a69de7332 [benchmark] Have legacy tests use BenchmarkInfo and combine this with registered benches.
*NOTE* We always prefer a registered benchmark if we have one.

I am going to use BenchmarkInfo to solve the "create data for benchmark while we
are already timing" problem. I am going to add a field to BenchmarkInfo that if
it is not-null is called before we start measuring time. This closure can be
used to initialize any global data structures/etc.

But to do this, I need to be able to combine the registered and legacy
not-registered benchmarks.
2017-09-27 12:46:38 -07:00
Michael Gottesman
77acbe82b7 [benchmark] Rename BenchmarkCategories => BenchmarkCategory.
This is an enum that represents a single category of benchmarks. Per the API
guidelines this should really be singular.
2017-09-26 19:28:34 -07:00
Michael Gottesman
45b1609c23 [benchmark] Make BenchmarkCategories a StringEnum.
This ensures that we get BenchmarkCategories <-> String for free and enables the
code that implemented that transform to be deleted.
2017-09-26 19:28:05 -07:00
Michael Gottesman
d6c6ba722a [benchmark] Add some comments to BenchmarkInfo's properties. 2017-09-26 19:04:22 -07:00
Andrew Trick
7a4adbe980 Fix enum indentation. 2017-09-22 21:44:05 -07:00
Joe Shajrawi
ca6ccb4864 Benchmark categorization support 2017-09-22 17:39:04 -07:00
Andrew Trick
2e60052d1d ObjectAllocation is a .cpubench. 2017-09-22 14:52:47 -07:00
Andrew Trick
d9af4c5f45 Introduce BenchmarkInfo and BenchmarkCategories. 2017-09-22 12:49:59 -07:00
Erik Eckstein
fadd2d856f benchmarks: add a getString() utility function.
To be used to prevent constant propagation for benchmark input values.
2017-06-21 17:21:51 -07:00
Erik Eckstein
f657fc5a53 benchmarks: add a getInt() utility function.
To be used to prevent constant propagation for benchmark input values.
2017-06-19 20:30:20 -07:00
eeckstein
087b84e800 Merge pull request #9330 from palimondo/check-results-error-msg
[benchmark] CheckResults with auto-generated error message
2017-05-12 08:47:40 -07:00
practicalswift
764ce41c9a [gardening] Fix a vs an typos. 2017-05-09 20:47:27 +02:00
Dave Abrahams
e32fb8badb Remove interpolated strings from benchmark CheckResults
This call was in many cases skewing the benchmark results.

Note: Intentionally staging this in without removing the old overload initially.
2017-05-05 10:25:02 -07:00
Pavol Vaskovic
dcd98cc04f CheckResults with auto-generated error message
In order to minimize impact of results checking on test performance, this removes the @autoclosure for error message.

Added new version of `CheckResults` that takes only `resultsMatch: Bool` - rest of the parameters are defaulted to `StaticString`s for method and file name, plus line number. Old method was deprecated, but left in place as tool for debugging failing checks. All tests were move to use the new method.
2017-05-05 14:08:13 +02:00
Erik Eckstein
fc4b5fa25d benchmarks: add a blackHole function, which can be used to prevent the optimizer to remove a result of a computation.
It’s similar to the _blackHole function in the stdlib unit tests.
2017-05-03 09:05:44 -07:00