Commit Graph

492 Commits

Author SHA1 Message Date
Pavol Vaskovic
377ee464d2 [benchmark] Test error handling parsing arguments
* Fix: flushing stdout before crashing to enable testing.
* Added tests that verify reporting of errors when the parsing of command line arguments fails.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
c198f442d4 [benchmark] Measure environment with rusage
Measure and report system environment indicators during benchmark execution:

* Memory usage with maximum resident set size (MAX_RSS) in bytes

Proxy indicators of system load level:

* Number of Involuntary Context Switches (ICS)
* Number of Voluntary Context Switches (VCS)

MAX_RSS delta is always reported in the last column of the log report.

The `--verbose` mode additionaly reports full values measured before and after the benchmark execution as well as their delta for MAX_RSS, ICS and VCS.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
0dbbc3dda7 [benchmark][Gardening] Indices are String
The indices (test numbers) are strings on both ends of the IO — in user input as well as when printed to the console. We can spare few conversions and just store them directly as `String`.
2018-07-17 07:28:39 +02:00
Pavol Vaskovic
fce7a4551d [benchmark][Gardening] BenchmarkInfo replaces Test
The `Test`struct was forwarding everything to `BenchmarkInfo` and its only contribution was carrying of the index. Tuple is fine for that.
2018-07-17 07:28:39 +02:00
Pavol Vaskovic
0836452066 [benchmark][Gardening] BenchmarkResults formatting
Moved the formatting of`BenchmarkResults` into `runBenchmarks` function which already contained the logging of header and the special case of unsupported benchmark.
2018-07-17 07:28:39 +02:00
Pavol Vaskovic
c7fc745fff [benchmark] Removed bogus Totals stats
Report only the total number of executed tests.

Aggregating MIN, MAX and MEAN values for all executed benchmarks together (with microsecond precision!) has no statistical relevance.
2018-07-17 07:28:39 +02:00
Pavol Vaskovic
0efdd8d67f [benchmark][Gardening] Nicer header composition 2018-07-17 07:28:39 +02:00
Daiki Matsudate
a3552f393e [stdlib] Add compactMapValues(_:) to Dictionary (#15017)
add compact map values on hashed collections
2018-07-14 22:35:16 -07:00
Pavol Vaskovic
7f894268b2 [benchmark] Restore running benchmarks by numbers
Reintroduced feature lost during `BenchmarkInfo` modernization: All registered benchmarks are ordered alphabetically and assigned an index. This number can be used as a shortcut to invoke the test instead of its full name. (Adding and removing tests from the suite will naturally reassign the indices, but they are stable for a given build.)

The `--list` parameter now prints the test *number*, *name* and *tags* separated by delimiter.

The `--list` output format is modified from:
````
Enabled Tests,Tags
AngryPhonebook,[String, api, validation]
...
````
to this:
````
\#,Test,[Tags]
2,AngryPhonebook,[String, api, validation]
…
````
(There isn’t a backslash before the #, git was eating the whole line without it.)
Note: Test number 1 is Ackermann, which is marked as “skip”, so it’s not listed with the default `skip-tags` value.

Fixes the issue where running tests via `Benchmark_Driver` always reported each test as number 1. Each test is run independently, therefore every invocation was “first”. Restoring test numbers resolves this issue back to original state: The number reported in the first column when executing the tests is its ordinal number in the Swift Benchmark Suite.
2018-07-11 23:17:02 +02: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
d40ddabcd5 [benchmark] Fix: running with --num-iters=1
Fixed bug where the `elapsed_time` was always 0 when `--num-iters=1` was specified.
2018-07-11 23:17:02 +02:00
Pavol Vaskovic
8b03980cb0 [benchmark] DRY: Call setup and teardown only once 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
Karoy Lorentey
b954e6068d [benchmark] Add NSDictionary benchmarks for dictionaries bridged from Swift 2018-07-05 11:28:27 +01:00
Lance Parker
cdf9ab6657 hashing benchmarks for String 2018-07-02 17:44:50 -07:00
Karoy Lorentey
f7c4832bfe [benchmark] Fix integer overflow issues on 32-bit platforms
The automatic scaling mechanism may end up with iteration counts greater than 2^31, leading to integer overflow.
2018-06-15 16:56:26 -07:00
Michael Gottesman
7dbfaa2eff [benchmark] Change the swiftpm pm package to conditional ObjectiveCNoBridgingStubs on Xcode and SWIFT_PACKAGE.
Otherwise while xcrun swift build will work, a generate xcodeproject from
swiftpm will not.
2018-06-05 21:56:11 -07:00
Michael Gottesman
0a70ec336a [benchmark] Add swiftpm support for the benchmark suite.
This means that we can now edit benchmarks in Xcode! Keep in mind:

1. This is not an official build. It is just so we can use Xcode to edit files
and get IDE features.
2. I had to do a little hackery to keep the build the way it is today where all
single-source files are their own modules.
3. As long as we do not change the directory structure, everything should just
update and work since I added a little code that dynamically adds the tests.

Also, to do this I had to rename multi-source/PrimsSplit/main.swift =>
Prims_main.swift. That is because the name main.swift is special in some way and
I hit linker errors. By simply changing the name from main.swift =>
Prims_main.swift, everything is good. I am going to file a separate bug for
that.
2018-06-03 23:50:27 -07:00
Michael Gottesman
1124a37307 [benchmark] Add two low level Radix2CooleyTukey benchmarks. 2018-06-01 13:15:45 -07:00
Erik Eckstein
c70970c60f benchmarks: fix the handling of the --help command line option
It displayed the help if the option was _not_ specified.
2018-05-29 12:47:08 -07:00
Michael Gottesman
cee593c267 [benchmark] Add a small --help menu to the low level driver that just dumps the current valid options list.
We probably should have added this sooner...
2018-05-29 00:03:46 -07: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 Gottesman
4ddeba123d Merge pull request #16832 from gottesmm/pr-769c02db89f9caceec9c48e9e9f081fe78655b9a
[func-sig-opts][+0->+1] Add a benchmark that requires the optimizer t…
2018-05-24 22:57:03 -07:00
Michael Gottesman
0629afc3fe [func-sig-opts][+0->+1] Add a benchmark that requires the optimizer to propagate a +1 value from an opaque entry point through a simple linear call tree.
rdar://38196046
2018-05-24 18:12:05 -07:00
Michael Gottesman
1d5aca44f2 [func-sig-opts] Add a regression benchmark that shows overhead from +1->+0 without a corresponding +0->+1 optimization.
rdar://38196046
2018-05-24 16:16:42 -07:00
Karoy Lorentey
d282b1c541 Merge pull request #16413 from Azoy/random-unification
[stdlib] Random unification
2018-05-10 11:41:48 +01:00
Ben Rimmington
b65d0c1d11 Consolidate _stdlib_random functions (#2)
* Use the `__has_include` and `GRND_RANDOM` macros

* Use `getentropy` instead of `getrandom`

* Use `std::min` from the <algorithm> header

* Move `#if` out of the `_stdlib_random` function

* Use `getrandom` with "/dev/urandom" fallback

* Use `#pragma comment` to import "Bcrypt.lib"

* <https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp>
* <https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions>

* Use "/dev/urandom" instead of `SecRandomCopyBytes`

* Use `swift::StaticMutex` for shared "/dev/urandom"

* Add `getrandom_available`; use `O_CLOEXEC` flag

Add platform impl docs

Update copyrights

Fix docs

Add _stdlib_random test

Update _stdlib_random test

Add missing &

Notice about _stdlib_random

Fix docs

Guard on upperBound = 0

Test full range of 8 bit integers

Remove some gyb

Clean up integerRangeTest

Remove FixedWidthInteger constraint

Use arc4random universally

Fix randomElement

Constrain shuffle to RandomAccessCollection

warning instead of error

Move Apple's implementation

Fix failing test on 32 bit systems
2018-05-09 00:21:44 -05:00
Nate Cook
f146d17214 Revise documentation, add benchmarks (#3)
* [stdlib] Revise documentation for new random APIs

* [stdlib] Fix constraints on random integer generation

* [test] Isolate failing Random test

* [benchmark] Add benchmarks for new random APIs

Fix Float80 test

Value type generators

random -> randomElement

Fix some docs

One more doc fix

Doc fixes & bool fix

Use computed over explicit
2018-05-04 21:03:50 -05:00
Yuta Koshizawa
903f55b45b [benchmark] Add DictionaryKeysContains 2018-05-03 01:22:31 +09: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
Max Moiseev
9ee2fe9b10 Merge pull request #15376 from moiseev/filter-map-filter-map
[benchmark] Add a benchmark for .lazy.filter.map chaining...
2018-03-20 14:53:22 -07:00
Max Moiseev
c4e2b548dc [benchmark] Add a benchmark for .lazy.filter,map chaining...
... and functionally equivalent single call to .lazy.compactMap.

See https://forums.swift.org/t/introduce-lazy-version-of-compactmap/9835
for more info.
2018-03-20 11:54:18 -07:00
tbkka
848de7e84c Benchmark {Float,Double,Float80}.description (#15234)
* Benchmark {Float,Double,Float80}.description

This just tests how fast we can format the standard
floating-point types.  It also includes a test that
uses the result, to ensure that future optimized
_creation_ of the string doesn't incidentally pessimize
_use_ of the results.

* Benchmark {Float,Double,Float80}.description

This just tests how fast we can format the standard
floating-point types.  It also includes a test that
uses the result, to ensure that future optimized
_creation_ of the string doesn't incidentally pessimize
_use_ of the results.

* Add benchmarks for values close to 1 + other review suggestions
2018-03-15 14:09:35 -04:00
Tony Parker
130ce14f16 Merge pull request #15221 from parkera/parkera/data_benchmarks
Updated Data benchmarks
2018-03-15 09:01:18 -07:00
Tony Parker
19c6ccf5af Updated Data benchmarks 2018-03-13 17:29:50 -07:00
Karoy Lorentey
c2eccf2b4d [benchmark] Add benchmarks for Dictionary operations with quadratic behavior
Dictionary and Set currently exhibit O(n^2) behavior for certain operations involving copying elements in bulk. Add benchmarks to verify an upcoming fix and to catch regressions later.

https://bugs.swift.org/browse/SR-3268
2018-03-13 19:42:45 +00:00
Michael Ilseman
7f1ba5d22d Merge pull request #14992 from milseman/bench_builder
[benchmark] More StringBuilder/Interpolation benchmarks
2018-03-06 15:09:01 -08:00
swift-ci
8ace7b8f7f Merge pull request #14988 from xwu/benchmark-fp-properties 2018-03-05 18:18:22 -08:00
Xiaodi Wu
7cb94890b4 Add binary floating-point properties benchmarks 2018-03-05 19:26:03 -06:00
Michael Ilseman
87b24738d8 [benchmark] Add string interpolation benchmarks
Add some benchmarks for when the whole interpolated string is small,
and when it is very large but every segment is pretty small.
2018-03-05 14:25:41 -08:00
Kamil Pyć
782ee2010a Further optimisation with guard 2018-03-03 19:57:27 +01:00
Kamil Pyć
8b997b4965 Removed redundant check
Since init for Int with empty string returns nil there is no need for additional checking for empty string
2018-03-03 05:54:10 +01:00
Huon Wilson
2130ba9808 Revert "[benchmark] Add interpolation; more stable builder" 2018-03-01 19:05:10 -08:00
Michael Ilseman
959f45edc0 [benchmark] Add string interpolation benchmarks
Add some benchmarks for when the whole interpolated string is small,
and when it is very large but every segment is pretty small.
2018-02-28 19:15:42 -08:00
swift-ci
3956205f76 Merge pull request #14662 from airspeedswift/remove-where-benchmark 2018-02-15 17:17:56 -08:00
Ben Cohen
220883f20c Sequence algorithm benchmarks (#14663) 2018-02-15 16:07:00 -08:00
Ben Cohen
1e820dc505 Add benchmarks based on different remove(where:) implementations 2018-02-15 16:03:38 -08:00
Karoy Lorentey
ba978d3338 [benchmark] Add benchmark exercising the hash compression function 2018-02-08 15:19:22 +00:00
Ben Cohen
cfd322593c Add Queue benchmark that tests popLast generically and concretely (#14393) 2018-02-03 11:53:05 -08:00