Skip to content

Commit da5c435

Browse files
committed
update
1 parent 6403f98 commit da5c435

34 files changed

Lines changed: 1952 additions & 583 deletions

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build-and-test:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Configure
19+
run: cmake -B build
20+
21+
- name: Build
22+
run: cmake --build build
23+
24+
- name: Test
25+
run: ctest --test-dir build --output-on-failure

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# CMake build directory
2+
build/
3+
14
# Prerequisites
25
*.d
36

CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
4+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
5+
endif()
6+
7+
project(testingRNG C CXX)
8+
9+
enable_testing()
10+
11+
set(SOURCE_DIR ${PROJECT_SOURCE_DIR}/source)
12+
13+
option(BUILD_SPEED "Build speed benchmarks" ON)
14+
option(BUILD_UNIT "Build unit tests" ON)
15+
option(BUILD_PRACTRAND "Build PractRand test harnesses" ON)
16+
option(BUILD_TESTU01 "Build TestU01 test harnesses" ON)
17+
option(BUILD_ENTROPY "Build entropy test harnesses" ON)
18+
19+
if(BUILD_SPEED)
20+
add_subdirectory(speed)
21+
endif()
22+
23+
if(BUILD_UNIT)
24+
add_subdirectory(unit)
25+
endif()
26+
27+
if(BUILD_PRACTRAND)
28+
add_subdirectory(practrand)
29+
endif()
30+
31+
if(BUILD_TESTU01)
32+
add_subdirectory(testu01)
33+
endif()
34+
35+
if(BUILD_ENTROPY)
36+
add_subdirectory(entropy)
37+
endif()

README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,56 @@ the C (and C++) compiler. Make sure you have installed the command-line utilitie
2626

2727
(Note: We assume a recent x64 processor. TestU01, in particular, does not easily build on some ARM-based systems.)
2828

29+
## Building
30+
31+
We use CMake as our build system. From the project root:
32+
33+
```
34+
cmake -B build
35+
cmake --build build
36+
ctest --test-dir build
37+
```
38+
39+
By default, the build compiles in Release mode and builds everything: speed benchmarks, unit tests, PractRand test harnesses, entropy test harnesses, and TestU01 test harnesses. TestU01 is built automatically from the included `testu01/TestU01.zip` archive.
40+
41+
### CMake options
42+
43+
| Option | Default | Description |
44+
|--------|---------|-------------|
45+
| `BUILD_SPEED` | ON | Speed benchmarks |
46+
| `BUILD_UNIT` | ON | Unit tests |
47+
| `BUILD_PRACTRAND` | ON | PractRand test harnesses |
48+
| `BUILD_ENTROPY` | ON | Entropy test harnesses |
49+
| `BUILD_TESTU01` | ON | TestU01 test harnesses (built from included archive) |
50+
2951
## Usage
3052

31-
You can run the tests by going to a bash shell (Terminal) and executing a few commands.
53+
### Speed:
54+
```
55+
./build/speed/rng
56+
```
3257

33-
#### PractRand:
58+
### PractRand:
3459
```
3560
cd practrand
3661
./runtests.sh
3762
```
3863

3964
The PractRand benchmark takes some time to complete because we analyze a large volume of random numbers.
4065

41-
#### TestU01:
66+
### TestU01:
4267
```
4368
cd testu01
4469
./bigcrushall.sh
4570
```
4671

4772
The TestU01 benchmark "big crush" (``bigcrushall.sh``) might take days. It outputs its results in the current
48-
directory (``testu1``, but we copied already computed in the ``results`` subdirectory.
73+
directory (``testu01``), but we copied already computed results in the ``results`` subdirectory.
4974
A parallel version (``bigcrushallparallel.sh``) will test multiple generators at the same time, up to the number of detected CPU threads.
5075

51-
There are also extensive scripts that generate many (100) seeds and test generators, the script take
76+
There are also extensive scripts that generate many (100) seeds and test generators, the scripts take
5277
the form ``rand*.sh``, one per generator. They output their results in their ``longresults`` subdirectory.
5378

54-
#### Speed:
55-
It is interesting to assess running speed as well. This can be done quickly:
56-
57-
```
58-
cd speed
59-
make
60-
make test
61-
```
62-
63-
Note that the speed tests assume a recent x64 processor (e.g., they would not work
64-
on ARM processors).
65-
6679
## The contenders
6780

6881
- splitmix64 is a random number generator in widespread use and part of the standard Java API, we adapted a port to C produced by Vigna. It produces 64-bit numbers.

0 commit comments

Comments
 (0)