Commit Graph

8 Commits

Author SHA1 Message Date
Karoy Lorentey
8944591e71 [benchmark] Simplify benchmark registration 2021-09-15 22:08:08 -07:00
Karoy Lorentey
8910b75cfe [benchmark] Stop capitalizing function and variable names 2021-09-15 22:08:07 -07:00
Stephen Canon
f538b49fc9 Use the "nearly divisionless" algorithm on all targets. (#37920)
* Use the "nearly divisionless" algorithm on all targets.

We have multipliedFullWidth available everywhere now, so we don't need to carry around the old implementation on 32b targets.

Also adds a few more benchmarks for random number generation.

* Obscure the range boundaries for some of the new random value benchmarks.

When these are visible compile-time constants, the compiler is smart enough to evaluate the division in the "nearly divisionless" algorithm, which makes it completely divisionless. That's good, but it obscures what the runtime performance of the algorithm will be when the bounds are _not_ available as compile-time constants. Thus, for some of the newly-added benchmarks, we pass the upper bound through `identity` to hide it from the optimizer (this is imperfect, but it's the simplest tool we have).

We don't want to do this for all the tests for two reasons:
- compile-time constant bounds are a common case that should still be reflected in our testing
- we don't want to perturb existing benchmark results more than we have to.
2021-06-15 20:27:49 -04:00
Pavol Vaskovic
9706668e0a [benchmark] RandomIntegersLCG futureproofed
Allow for future change in algorithm that generates random integers in range.
2019-06-07 06:14:40 +02:00
Pavol Vaskovic
91f25f68b9 [benchmark] RandomValues Legacy Factor 2019-01-22 09:26:05 +01:00
Karoy Lorentey
d66d6b4a84 [benchmark] RandomIntegersLCG: Fix result check on 32-bit platforms
Values returned by random APIs depend on the bitWidth of the underlying integer type; make sure we use a consistent integer width when expecting particular results.
2018-06-15 16:58:05 -07: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