-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* timing experiment Java 17+ * Update pom.xml * updated benchmarks * Update TimeZigguratVersusJavaBuiltin.java * change benchmark mode, etc * Create results.txt * moved directories * update experiments * renamed directory * data from runs of new version * deternine which gaussian alg for all PRNGs * Create README.md * Create README.md * Create README.md * Update README.md * Update README.md * Update README.md
- Loading branch information
Showing
11 changed files
with
1,051 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
target/ | ||
dependency-reduced-pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Experiments, Sample Code, and Other Misc | ||
|
||
This directory contains source code of experiments with the | ||
library, sample code, and other misc items, as follows. | ||
|
||
## Experiments with the Ziggurat Library and Java 17 | ||
|
||
The code in the directory [timing17](timing17) can be used to reproduce the experiments of the following paper, which among other things explores the relevance of the library for Java 17+: | ||
|
||
> Vincent A. Cicirello. 2024. [Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm](https://reports.cicirello.org/24/009/). Technical Report ALG-24-009, Cicirello.org, May 2024. [[PDF]](https://reports.cicirello.org/24/009/ALG-24-009.pdf) | ||
## Which Gaussian Algorithm Does Java Use | ||
|
||
The code in the directory [properties](properties) extracts a list of all of the | ||
random number generators for Java 17, and determines what implementation of | ||
`nextGaussian` each uses. Classes that inherit the default in Java 17 use a modified | ||
ziggurat, which is faster than the original ziggurat algorithm. The `Random` class, | ||
and the classes that extend it override the default with the slow polar method. Those | ||
are cases where our implementation of the original ziggurat algorithm is still relevant | ||
for Java 17+ applications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Which Gaussian Algorithm Does Java Use | ||
|
||
The code in this directory extracts a list of all of the random number generators | ||
for Java 17, and determines what implementation of `nextGaussian` each uses. Classes | ||
that inherit the default in Java 17 use a modified ziggurat, which is faster than | ||
the original ziggurat algorithm. The `Random` class, and the classes that extend it | ||
override the default with the slow polar method. Those are cases where our implementation | ||
of the original ziggurat algorithm is still relevant for Java 17+ applications. | ||
|
||
## Building with Maven | ||
|
||
To compile, execute the following within this directory: | ||
|
||
```Shell | ||
mvn clean package | ||
``` | ||
|
||
## Running | ||
|
||
To run, execute the following within this directory: | ||
|
||
```Shell | ||
java -cp target/what-gaussian-1.0.0.jar org.cicirello.experiments.whatgaussian.WhatGaussian | ||
``` | ||
|
||
## Output | ||
|
||
If you just want to inspect the output from my run, see the | ||
file [what-gaussian-implementation.txt](what-gaussian-implementation.txt). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.cicirello</groupId> | ||
<artifactId>what-gaussian</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Check which RandomGenerators use default Gaussian algorithm.</name> | ||
|
||
<description>Determines which of Java's builtin pseudorandom number generators | ||
use the RandomGenerator interface's default algorithm for nextGaussian, which | ||
override it. | ||
</description> | ||
|
||
<url>https://github.com/cicirello/ZigguratGaussian</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>GPL-3.0-or-later</name> | ||
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url> | ||
<distribution>repo</distribution> | ||
<comments> | ||
Check which RandomGenerators use default Gaussian algorithm. | ||
Copyright (C) 2024 Vincent A. Cicirello. | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see https://www.gnu.org/licenses/. | ||
</comments> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Vincent A Cicirello</name> | ||
<email>development@cicirello.org</email> | ||
<url>https://www.cicirello.org/</url> | ||
<organization>Cicirello.org</organization> | ||
<organizationUrl>https://www.cicirello.org/</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<organization> | ||
<name>Cicirello.org</name> | ||
<url>https://www.cicirello.org/</url> | ||
</organization> | ||
|
||
<profiles> | ||
<profile> | ||
<id>analysis</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.spotbugs</groupId> | ||
<artifactId>spotbugs-maven-plugin</artifactId> | ||
<version>4.8.1.0</version> | ||
<configuration> | ||
<htmlOutput>true</htmlOutput> | ||
<excludeFilterFile>${session.executionRootDirectory}/spotbugs-exclude.xml</excludeFilterFile> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.h3xstream.findsecbugs</groupId> | ||
<artifactId>findsecbugs-plugin</artifactId> | ||
<version>1.12.0</version> | ||
</plugin> | ||
</plugins> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>spotbugs</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<issueManagement> | ||
<system>github</system> | ||
<url>https://github.com/cicirello/ZigguratGaussian/issues</url> | ||
</issueManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.cicirello</groupId> | ||
<artifactId>ziggurat</artifactId> | ||
<version>1.0.5</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.release>17</maven.compiler.release> | ||
<maven.javadoc.skip>true</maven.javadoc.skip> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
<configuration> | ||
<release>17</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.6.2</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<failOnWarnings>false</failOnWarnings> | ||
<failOnError>true</failOnError> | ||
<windowtitle>Check which RandomGenerators use default Gaussian algorithm</windowtitle> | ||
<doctitle>Check which RandomGenerators use default Gaussian algorithm</doctitle> | ||
<author>true</author> | ||
<version>false</version> | ||
<nosince>true</nosince> | ||
<notimestamp>true</notimestamp> | ||
<bottom><![CDATA[Copyright © 2024 <a href=\"https://www.cicirello.org/\" target=_top>Vincent A. Cicirello</a>. All rights reserved.]]></bottom> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.spotify.fmt</groupId> | ||
<artifactId>fmt-maven-plugin</artifactId> | ||
<version>2.21.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>format</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
72 changes: 72 additions & 0 deletions
72
experiment/properties/src/main/java/org/cicirello/experiments/whatgaussian/WhatGaussian.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Check which RandomGenerators use default Gaussian algorithm. | ||
* Copyright (C) 2024 Vincent A. Cicirello | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.cicirello.experiments.whatgaussian; | ||
|
||
import java.util.concurrent.ThreadLocalRandom; | ||
import java.util.random.RandomGenerator; | ||
import java.util.random.RandomGeneratorFactory; | ||
|
||
/** | ||
* Determines which of Java's builtin pseudorandom number generators use the RandomGenerator | ||
* interface's default algorithm for nextGaussian, which override it. | ||
* | ||
* @author <a href=https://www.cicirello.org/ target=_top>Vincent A. Cicirello</a>, <a | ||
* href=https://www.cicirello.org/ target=_top>https://www.cicirello.org/</a> | ||
*/ | ||
public final class WhatGaussian { | ||
|
||
/** | ||
* Entrypoint for program. | ||
* | ||
* @param args unused | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
System.out.printf("%10s %21s %s\n", "Group", "RandomGenerator", "Where nextGaussian declared"); | ||
RandomGeneratorFactory.all() | ||
.sorted((f1, f2) -> f1.group().compareTo(f2.group())) | ||
.forEach( | ||
generatorFactory -> { | ||
String name = generatorFactory.name(); | ||
String group = generatorFactory.group(); | ||
RandomGenerator r = generatorFactory.create(); | ||
try { | ||
String classThatDeclaresNextGaussian = | ||
r.getClass().getMethod("nextGaussian").getDeclaringClass().getName(); | ||
System.out.printf("%10s %21s %s\n", group, name, classThatDeclaresNextGaussian); | ||
} catch (NoSuchMethodException exception) { | ||
System.out.println( | ||
"Something highly unexpexpected occured. A method with a default not found."); | ||
} | ||
}); | ||
try { | ||
String classThatDeclaresNextGaussian = | ||
ThreadLocalRandom.current() | ||
.getClass() | ||
.getMethod("nextGaussian") | ||
.getDeclaringClass() | ||
.getName(); | ||
System.out.printf( | ||
"%10s %21s %s\n", "Legacy", "ThreadLocalRandom", classThatDeclaresNextGaussian); | ||
} catch (NoSuchMethodException exception) { | ||
System.out.println( | ||
"Something highly unexpexpected occured. A method with a default not found."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Group RandomGenerator Where nextGaussian declared | ||
LXM L32X64MixRandom java.util.random.RandomGenerator | ||
LXM L128X128MixRandom java.util.random.RandomGenerator | ||
LXM L64X128MixRandom java.util.random.RandomGenerator | ||
LXM L128X1024MixRandom java.util.random.RandomGenerator | ||
LXM L64X128StarStarRandom java.util.random.RandomGenerator | ||
LXM L64X256MixRandom java.util.random.RandomGenerator | ||
LXM L128X256MixRandom java.util.random.RandomGenerator | ||
LXM L64X1024MixRandom java.util.random.RandomGenerator | ||
Legacy SecureRandom java.util.Random | ||
Legacy Random java.util.Random | ||
Legacy SplittableRandom java.util.random.RandomGenerator | ||
Xoroshiro Xoroshiro128PlusPlus java.util.random.RandomGenerator | ||
Xoshiro Xoshiro256PlusPlus java.util.random.RandomGenerator | ||
Legacy ThreadLocalRandom java.util.Random |
Oops, something went wrong.