Commit Graph

492 Commits

Author SHA1 Message Date
Pavol Vaskovic
f017d98050 [benchmark] Refactor to report samples in μs
Moved the adjustment of `lastSampleTime` to account for the `scale` (`numIters`) and conversion to microseconds into SampleRunner’s `measure` method.
2018-08-31 07:32:18 +02:00
Pavol Vaskovic
a03aede90d [benchmark] Gardening: scale was always Int
Since the `scale` (or `numIters`) is passed to the `test.runFunction` as `Int`, the whole type-casting dance here was just silly!
2018-08-31 07:32:17 +02:00
Pavol Vaskovic
bf4a343124 [benchmark] Gardening: numSamples UInt vs Int
Type check command line argument to be non-negative, but store value in currency type `Int`.
2018-08-31 07:32:16 +02:00
Pavol Vaskovic
77dff0a1d7 [benchmark] Gardening: afterRunSleep is UInt32 2018-08-31 07:32:14 +02:00
Pavol Vaskovic
aa4b84934a [benchmark] Move stats computation to BenchResults 2018-08-31 07:32:12 +02:00
Pavol Vaskovic
0db20feda2 [benchmark] Fix index computation for quantiles
Turns out that both the old code in `DriverUtils` that computed median, as well as newer quartiles in `PerformanceTestSamples` had off-by-1 error.

It trully is the 3rd of the 2 hard things in computer science!
2018-08-31 07:32:10 +02:00
Pavol Vaskovic
5cd9f53840 [benchmark] Refactor min max median computation
We can spare 2 array passes (for min and max), if we just sort first.
2018-08-31 07:32:09 +02:00
Pavol Vaskovic
963995fa2b [benchmark] Refactor mean and stdev computation 2018-08-31 07:32:08 +02:00
Pavol Vaskovic
974994c13a [benchmark] Gardening: Timer Parasite Control
Improve conformance to Swift Naming Guidelines
https://swift.org/documentation/api-design-guidelines/#parameter-names

Removed the gross undescores and ticks from parameter names. Ticks are ectoparasites feeding on the blood. We are just measuring time and there is also no [mysterious ticking noise](http://bit.ly/TickNoise) here either…
2018-08-31 07:32:06 +02:00
Pavol Vaskovic
c1a694de30 [benchmark] Gardening: Extract constant oneSecond 2018-08-31 07:32:04 +02:00
Pavol Vaskovic
b373132548 [benchmark] Gardening: Code format class Timer 2018-08-31 07:32:03 +02:00
Pavol Vaskovic
e6cff27bab [benchmark] Gardening: Indentation of .listTests 2018-08-31 07:32:02 +02:00
swift-ci
33d95a3d22 Merge pull request #18984 from graydon/follow-my-simple-instruction 2018-08-30 16:20:29 -07:00
Graydon Hoare
e7903f95c2 [benchmark] Compensate for missing header in some SDKs. 2018-08-28 14:00:19 -07:00
Pavol Vaskovic
b482a049c3 [benchmark] Gentleman yields. Don’t be a CPU hog!
It pays off of to be a nice process and yield the processor at regular intervals, to prevent having measured samples corrupted by preemptive multitasking.

When the scheduled time slice (10ms on Mac OS) is probably about to expire during the next measurement, we voluntarily yield  and resume the measurement within a fresh scheduler quantum.

This cooperative approach to multitasking improves the sample quality and robustness of the measurement process.
2018-08-28 05:37:43 +02:00
Pavol Vaskovic
7969be1c35 [benchmark] Explicitly enable static dispatch
Marking `Timer` and `SampleRunner` classes as `final` to make sure their methods use static dispatch.
2018-08-28 05:37:43 +02:00
Pavol Vaskovic
c98006c10b [benchmark] Gardening: Fixed indentation 2018-08-28 05:37:43 +02:00
Graydon Hoare
6d32861df7 [benchmark] Fix module-inclusion bug caused by my forgetting about case-insensitive filesystems. 2018-08-27 15:18:55 -07:00
Graydon Hoare
94725dff2b [benchmark] Add preliminary helper for measuring instructions executed. 2018-08-25 01:29:37 -07:00
Pavol Vaskovic
7ae5d7754c [benchmark] Report totals as a sentence
Clean up after removing bogus agregate statistics from last line of the log. It makes more sense to report the total number of executed benchmarks as a sentence that trying to fit into the format of preceding table.

Added test assertion that `run_benchmarks` return csv formatted log, as it is used to write the log into file in `log_results`.
2018-08-23 18:01:46 +02:00
Pavol Vaskovic
f29fef6b67 [benchmark] Print delim in verbose config 2018-08-16 08:11:13 +02:00
Kirill Chibisov
38db0d7ce2 Added benchmark for heapSort path of stdlib sort
This benchmark makes sorting benchmarks more complete. Now we
can measure all paths of stdlib sorting function.
2018-08-13 16:11:01 +03: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
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
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