Commit Graph

713 Commits

Author SHA1 Message Date
Erik Eckstein
c1ff9bcedc benchmarks: add a script to report code size of benchmark files 2018-08-07 13:16:24 -07:00
Erik Eckstein
f82da4113b benchmarks: minor comment fix 2018-08-07 13:15:23 -07:00
Erik Eckstein
89d07e5998 benchmarks: add a script to do a very fast check of which benchmarks changed.
Runs ~ 1 min to compare two benchmark builds.
2018-08-03 10:17:53 -07:00
Erik Eckstein
729989473f benchmarks: fix the iteration count for some benchmarks
So that a single iteration is within ~2ms (and also not too short).
2018-07-31 10:59:33 -07:00
Erik Eckstein
868c5a1fb7 benchmarks: Marking some benchmarks as unstable
The noise for those benchmarks even cannot be removed by using a high sample count.
2018-07-31 10:59:33 -07:00
Erik Eckstein
30cc37e5f4 benchmarks: fix the Chars benchmark by adding blackHoles and testing all possible Char comparisons 2018-07-31 10:59:33 -07:00
Erik Eckstein
2839c1707d benchmarks: fix the Calculator benchmark by covering more String compare test cases 2018-07-31 10:59:33 -07:00
Erik Eckstein
1a161c28ae benchmarks: compile with the new -align-module-to-page-size option, if supported by the compiler
To stabilize the benchmark results.
2018-07-27 17:15:14 -07:00
eeckstein
b042215abd Merge pull request #18211 from palimondo/fluctuation-of-the-pupil
[benchmark] Alphabetic sorting of tests and warning about incorrect use of memory option
2018-07-25 14:45:23 -07:00
Erik Eckstein
53f2660e62 benchmarks: Convert the PartialApplyDynamicType into a lit test
This benchmark was added to test if the compiler crashes.
For some reason it was added as benchmark and not as lit test.
It has no value as benchmark anyway because the compiler optimizes away pretty much everything.
2018-07-25 11:32:23 -07:00
Pavol Vaskovic
1a382ab775 [benchmark] Warn about incorrect --memory use 2018-07-25 08:02:28 +02:00
Pavol Vaskovic
a61a756b4d [benchmark] Fix: alphabetic sorting of tests 2018-07-25 07:45:07 +02: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
Erik Eckstein
50db6f1ed3 benchmarks: fix the setup functions of the CharacterProperties benchmark.
Force all globals to be initialized in the setup functions
2018-07-24 20:20:23 -07:00
Erik Eckstein
f1afba1ad1 benchmarks: adapted some iteration counts and/or workload sizes for benchmarks.
Those are benchmarks which took way too long or short to execute a single iteration or benchmarks which changed in time anyway because of previous fixes.

I renamed those benchmarks so that they are now treated as "new" benchmarks.
2018-07-24 20:20:23 -07:00
Erik Eckstein
f6c24a05cc benchmarks: extract setup code into the setUpFunction in some benchmarks where setup time is significant 2018-07-24 20:20:23 -07:00
Erik Eckstein
8876c24104 benchmarks: add some blackHole calls to prevent the optimizer removing important parts of a benchmark 2018-07-24 20:18:17 -07:00
Erik Eckstein
1a7bee55c6 benchmarks: fix the iteration count of some benchmarks.
Some benchmarks wrongly executed the loop N+1 times ("0...N" instead of "0..<N")

mt
2018-07-24 20:18:17 -07:00
Ben Cohen
345879429b [stdlib] Take several underscored stdlib functions private (#18134)
* Make _sanityCheck internal

* Make _debugPrecondition internal

* Make Optional._unsafelyUnwrappedUnchecked internal.

* Make _precondition internal

* Switch Foundation _sanityChecks to assertions

* Update file check tests

* Remove one more _debugPrecondition

* Update Optimization-with-check tests
2018-07-24 18:26:19 -07:00
eeckstein
46a83909c6 Merge pull request #18124 from palimondo/fluctuation-of-the-pupil
[benchmark] Measure memory with rusage and a TON of gardening
2018-07-23 12:40:38 -07:00
Pavol Vaskovic
362f925e37 [benchmark][Gardening] Docs and error handling
* Improved documentation.
* Corrected`fflush` usage in `parse` error handling.
* Removed unused `passThroughArgs`.
2018-07-23 18:01:23 +02:00
Pavol Vaskovic
4ed3dcfcc5 [benchmark][Gardening] --sample-time renaming
Sample time is a better name for what was previously called `iter-scale`.
2018-07-23 17:15:54 +02:00
Pavol Vaskovic
df5ccf3e26 [benchmark][Gardening] Better naming and comments
* Restored property doc comments on `TestConfig`
* Better name for func `usage` is `getResourceUtilization`
2018-07-23 11:17:16 +02:00
Pavol Vaskovic
19613733a4 [benchmark] Log the MAX_RSS only w/ --memory flag
Printing of the MAX_RSS is now hidden behind the optional `--memory` flag.
2018-07-22 06:25:23 +02:00
Ben Cohen
4694310e51 [stdlib] Some minor cleanup (#18130)
* Remove case destructuring to _

* Remove some Iterator.Element

* Which idiot wrote this? Oh.

* Switch NibbleSort to just use default impls... shouldn't change perf
2018-07-21 17:29:57 -07:00
Pavol Vaskovic
f89d41ad3b [benchmark] Print detailed argument help
The `--help` option now prints standard usage description with documentaion for all arguments:

````
 $ Benchmark_O --help
usage: Benchmark_O [--argument=VALUE] [TEST [TEST ...]]

positional arguments:
 TEST           name or number of the benchmark to measure

optional arguments:
 --help         show this help message and exit
 --num-samples  number of samples to take per benchmark; default: 1
 --num-iters    number of iterations averaged in the sample;
                default: auto-scaled to measure for 1 second
 --iter-scale   number of seconds used for num-iters calculation
                default: 1
 --verbose      increase output verbosity
 --delim        value delimiter used for log output; default: ,
 --tags         run tests matching all the specified categories
 --skip-tags    don't run tests matching any of the specified
                categories; default: unstable,skip
 --sleep        number of seconds to sleep after benchmarking
 --list         don't run the tests, just log the list of test
                numbers, names and tags (respects specified filters)
````
2018-07-21 22:58:44 +02:00
Pavol Vaskovic
0c0ed3d35d [benchmark][Gardening] Moved parseArgs into parser
The `parseArgs` funtion is now a private method on `ArgumentParser`.

Removed `Arguments` struct and moved the `Argument` as a nested struct into the parser.

Adjusted error messages and the corresponding checks.
2018-07-21 15:53:09 +02:00
Pavol Vaskovic
50c79c5972 [benchmark][Gardening] Local parser error handling
In case of invalid command line arguments, there is no reasonable recovery, the `ArgumentParser` can exit the program itself.  It is therefore no longer necessary to propagate the `ArgumentError`s outside of the parser.
2018-07-21 13:30:32 +02:00
Pavol Vaskovic
f674dd5cf0 [benchmark][Gardening] Handle --help inside parser
Moved the printing of help message inside the `ArgumentParser`, which has all the necessary info.

Added test that checks the `--help` option.
2018-07-21 13:16:08 +02:00
Pavol Vaskovic
e5cbfccd22 [benchmark][Gardening] Declarative ArgumentParser
The `ArgumentParser` now has a configuration phase which specifies the supported arguments and their handling. The configured parser is then executed using the `parse` method which returns the parsed result.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
9f902866ea [benchmark][Gardening] Extracted ArgumentParser
Moved the argument parsing logic into new class `ArgumentParser`. The `checked` function is also moved to the ArgParse.swift, next to the parser.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
1841ddef5b [benchmark][Gardening] Unified argument parsing
Renamed `optionalArg` to `parseArg` because it can now also handle the positional arguments. Now all the command line arguments are handled through this function.

Minor naming improvement of the `filterTests` parameter.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
48d1558d07 [benchmark][Gardening] Nested test filter funcs
Refactored `filterTests` to use two nested functions that better reveal the underlying logic.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
bfa198b952 [benchmark][Gardening] Immutable TestConfig
The `TestConfig` is now completely immutable. Arguments that are not necessary for running benchmarks were moved inside the config initialization, which also subsumed the  `printRunInfo` function for displaying the configuration details in verbose mode.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
50575b1cff [benchmark][Gardening] Introduce PartialTestConfig
Moving towards immutable TestConfig.

The pattern used is inspired by the`PartialBenchmarkConfig` from [criterion.rs](https://github.com/japaric/criterion.rs/blob/master/src/benchmark.rs).

The idea is to have a temporary mutable struct which collects the command line arguments and is filled by the “parser” (which will be extracted later). The partial configuration is used to initialize the immutable `TestConfig`.

The optionality of the command line parameters is represented by the corresponding properties being `Optional`. (Accidentaly, all our arguments are optional… but that’s beside the point.) Null coalescing operator is used to fill in the defaults during initialization.

For some reason, the compiler found `optionalArg` calls for `tags` and `skip-tags` ambiguous, when types changed to `Set<BenchmarkCategory>?`, which was resolved by providing fully qualified key paths for them (`\PartialTestConfig.tags`).
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
b76c946fb9 [benchmark][Gardening] processArguments is init
Processing command line arguments is an integral part of `TestConfig` initialization. Make it explicit.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
f2c4262ef0 [becnhmark][Gardening] Extracted checked function 2018-07-21 01:32:40 +02:00
Pavol Vaskovic
743c7ef15f [benchmark][Gardening] Grouped argument parsing
* Extracted tag parser
* Reordered all parsing of optional arguments to be grouped together.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
2e2848b215 [benchmark][Gardening] Arguments w/ optional value
Added handling for arguments that don’t have a value (flags), or whose values are optional (they can be empty). This covers all the argument types currently used in Benchmark_O with the single `optionalArg` function.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
7d19a03dce [benchmark] Gracefully type-check attribute values
We no longer crash when the argument value parsing fails, but report an error.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
647376c55f [benchmark][Gardening] Extract optionalArg func 2018-07-21 01:32:40 +02:00
Pavol Vaskovic
371f155258 [benchmark] Exit gracefully on argument errors
Refactored to use Swift’s idiomatic error handling.
In case of invalid argument errors, the message is printed to `stderr` and we exit gracefully with error code 1. We no longer crash the app in most cases.
2018-07-21 01:32:40 +02:00
Pavol Vaskovic
dd228d7181 [benchmark][Gardening] guard benchArgs 2018-07-21 01:32:40 +02:00
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