Skip to content

Commit fe9e34a

Browse files
committed
v2.0.0-RC-1 ArgsGenerators and ArgsSource preview
1 parent 055080e commit fe9e34a

File tree

4 files changed

+121
-31
lines changed

4 files changed

+121
-31
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Following a few guidelines so that others can quickly benefit from your contribu
1212

1313
## Code of Conduct
1414
This project and everyone participating in it is governed by Minimalist's
15-
[Code of Conduct](https://github.com/tegonal/minimalist/tree/main/.github/CODE_OF_CONDUCT.md).
15+
[Code of Conduct](https://github.com/tegonal/minimalist/tree/v2.0.0-RC-1/.github/CODE_OF_CONDUCT.md).
1616
By participating, you are expected to uphold this code. Please report unacceptable behaviour to info@tutteli.ch
1717

1818
## How to Contribute

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<!-- for main -->
2-
3-
[![Download](https://img.shields.io/badge/Download-v1.1.0-%23007ec6)](https://central.sonatype.com/artifact/com.tegonal.minimalist/minimalist/1.1.0)
2+
<!--
3+
[![Download](https://img.shields.io/badge/Download-v2.0.0--RC--1-%23007ec6)](https://central.sonatype.com/artifact/com.tegonal.minimalist/minimalist/2.0.0-RC-1)
44
[![EUPL 1.2](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License")
55
[![Quality Assurance](https://github.com/tegonal/minimalist/actions/workflows/quality-assurance.yml/badge.svg?event=push&branch=main)](https://github.com/tegonal/minimalist/actions/workflows/quality-assurance.yml?query=branch%3Amain)
66
[![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/tegonal/minimalist/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in discussions for help")
7-
7+
-->
88
<!-- for main end -->
99
<!-- for release -->
10-
<!--
11-
[![Download](https://img.shields.io/badge/Download-v1.1.0-%23007ec6)](https://central.sonatype.com/artifact/com.tegonal.minimalist/minimalist/1.1.0)
10+
11+
[![Download](https://img.shields.io/badge/Download-v2.0.0--RC--1-%23007ec6)](https://central.sonatype.com/artifact/com.tegonal.minimalist/minimalist/2.0.0-RC-1)
1212
[![EUPL](https://img.shields.io/badge/%E2%9A%96-EUPL%201.2-%230b45a6)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-11-12 "License")
1313
[![Newcomers Welcome](https://img.shields.io/badge/%F0%9F%91%8B-Newcomers%20Welcome-blueviolet)](https://github.com/tegonal/minimalist/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 "Ask in discussions for help")
14-
-->
14+
1515
<!-- for release end -->
1616

1717
# Minimalist
@@ -28,7 +28,7 @@ Although it might resemble a property based testing library, its focus is on tes
2828
❗ You are taking a *sneak peek* at the next version. It could be that some features you find on this page are not
2929
released yet.
3030
Please have a look at the README of the corresponding release/git tag. Latest
31-
version: [README of v1.1.0](https://github.com/tegonal/minimalist/tree/main/README.md).
31+
version: [README of v2.0.0-RC-1](https://github.com/tegonal/minimalist/tree/v2.0.0-RC-1/README.md).
3232

3333
---
3434

@@ -49,7 +49,7 @@ repositories {
4949
mavenCentral()
5050
}
5151
dependencies {
52-
testImplementation("com.tegonal.minimalist:minimalist:1.1.0")
52+
testImplementation("com.tegonal.minimalist:minimalist:2.0.0-RC-1")
5353
}
5454
```
5555

@@ -59,7 +59,7 @@ Minimum requirements:
5959

6060
# Code Documentation
6161

62-
Code documentation can be found on github-pages: <https://tegonal.github.io/minimalist/latest#/kdoc>.
62+
Code documentation can be found on github-pages: <https://tegonal.github.io/minimalist/2.0.0-RC-1/kdoc>.
6363

6464
# License
6565

build.gradle.kts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
plugins {
55
id("build-logic.published-kotlin-jvm")
66
id("code-generation.generate")
7-
alias(libs.plugins.nexus.publish)
87
id("me.champeau.jmh") version "0.7.3"
98
}
109

@@ -68,12 +67,6 @@ java {
6867
// }
6968
//}
7069

71-
nexusPublishing {
72-
repositories {
73-
sonatype()
74-
}
75-
}
76-
7770
jmh {
7871
profilers = listOf("gc")
7972
// run ./gradlew jmh -Pjmh.include=... to run a specific bench
@@ -88,7 +81,7 @@ Release & deploy a commit
8881
1. update main:
8982
9083
91-
export MNLMST_PREVIOUS_VERSION=1.1.0
84+
export MNLMST_PREVIOUS_VERSION=2.0.0-RC-1
9285
export MNLMST_VERSION=2.0.0-RC-1
9386
find ./ -name "*.md" | xargs perl -0777 -i \
9487
-pe "s@$MNLMST_PREVIOUS_VERSION@$MNLMST_VERSION@g;" \
@@ -99,7 +92,7 @@ perl -0777 -i \
9992
-pe "s/version = \"${MNLMST_VERSION}-SNAPSHOT\"/version = \"$MNLMST_VERSION\"/;" \
10093
./build.gradle.kts
10194
perl -0777 -i \
102-
-pe 's/(<!-- for main -->\n)\n([\S\s]*?)(\n<!-- for release -->\n)<!--\n([\S\s]*?)-->\n(\n# <img)/$1<!--\n$2-->$3\n$4\n$5/;' \
95+
-pe 's/(<!-- for main -->\n)\n([\S\s]*?)(\n<!-- for main end -->\n<!-- for release -->\n)<!--\n([\S\s]*?)-->\n(<!-- for release end -->)/$1<!--\n$2-->$3\n$4\n$5/;' \
10396
-pe 's/(---\n❗ You are taking[^-]*?---)/<!$1>/;' \
10497
./README.md
10598
git commit -a -m "v$MNLMST_VERSION"
@@ -113,7 +106,7 @@ git push
113106
b) git push origin "v$MNLMST_VERSION"
114107
c) Log in to github and create draft for the release
115108
116-
The tag is required for dokka in order that the externalLinkDocumentation and source-mapping works
109+
The tag is required for dokka in order that the externalLinkDocumentation works
117110
118111
3. update github pages:
119112
Assumes you have a minimalist-gh-pages folder on the same level as minimalist where the gh-pages branch is checked out
@@ -170,15 +163,30 @@ git push
170163
171164
cd ../minimalist
172165
173-
3. deploy to maven central:
166+
3. deploy to sonatype central portal:
174167
(assumes you have an alias named gr pointing to ./gradlew)
175-
a) echo "enter the sonatype user token"
176-
read SONATYPE_PW
177-
b) java -version 2>&1 | grep "version \"11" && ORG_GRADLE_PROJECT_sonatypePassword="$SONATYPE_PW" CI=true gr clean publishToSonatype
178-
c) Log into https://oss.sonatype.org/#stagingRepositories
179-
d) check if staging repo is ok
180-
e) close repo
181-
f) release repo
168+
a) java -version 2>&1 | grep "version \"11" && PUB=true CI=true gr clean pubToMaLo &&
169+
tmpDir=$(mktemp -d -t "minimalist-release-$MNLMST_VERSION-XXXXXXXXXX") &&
170+
find "$HOME/.m2/repository/com/tegonal/minimalist" -type d -name "*$MNLMST_VERSION" -print0 |
171+
while read -r -d $'\0' versionDir; do
172+
find "$versionDir" -type f -print0 | while read -r -d $'\0' file; do
173+
relPath="${file#"$HOME/.m2/repository/"}"
174+
mkdir -p "$tmpDir/$(dirname "$relPath")"
175+
cp "$file" "$tmpDir/$relPath"
176+
done
177+
done &&
178+
find "$tmpDir" -type f -not -name "*.md5" -not -name "*.sha1" -not -name "*.asc" -print0 |
179+
while read -r -d $'\0' file; do
180+
base=$(basename "$file");
181+
md5sum "$file" | awk '{ print $1 }' > "${file}.md5"
182+
sha1sum "$file" | awk '{ print $1 }' > "$file.sha1"
183+
done &&
184+
(cd "$tmpDir" zip -r "minimalist-$MNLMST_VERSION.zip" .) &&
185+
find "$tmpDir" -name "*.jar" | head -n 1 | xargs -I {} gpg --verify "{}.asc" "{}" &&
186+
echo "verify the correct gpg key was used (see above) and you might want to check the release in $tmpDir"
187+
b) Log into https://central.sonatype.com/publishing/deployments
188+
c) click on publish component and upload zip
189+
d) click on publish once verification is done
182190
183191
4. publish release on github
184192
1) Log in to github and publish draft
@@ -188,7 +196,7 @@ Prepare next dev cycle
188196
1. update main:
189197
190198
191-
export MNLMST_VERSION=1.1.0
199+
export MNLMST_VERSION=2.0.0-RC-1
192200
export MNLMST_NEXT_VERSION=1.2.0
193201
find ./ -name "*.md" | xargs perl -0777 -i \
194202
-pe "s@tree/v$MNLMST_VERSION@tree/main@g;" \

src/jmh/kotlin/com/tegonal/minimalist/PrefixSumBench.kt

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.tegonal.minimalist
22

33
import com.tegonal.minimalist.generators.impl.possibleMaxSizeSafeInIntDomainWithoutDivideTrick
4-
import com.tegonal.minimalist.generators.impl.prefixSumFast
5-
import com.tegonal.minimalist.generators.impl.prefixSumSlower
64
import org.openjdk.jmh.annotations.*
75
import java.util.concurrent.TimeUnit
86

@@ -59,3 +57,87 @@ open class PrefixSumBench {
5957
)
6058
}
6159
}
60+
61+
62+
private fun prefixSumFast(size: Int, numOfRangesWithMinSize: Int, minSize: Int, possibleMaxSize: Int) =
63+
prefixSumFast(
64+
size = size,
65+
numOfRangesWithMinSize = numOfRangesWithMinSize,
66+
minSize = minSize,
67+
possibleMaxSize = possibleMaxSize,
68+
plus = Int::plus,
69+
minus = Int::minus,
70+
times = Int::times,
71+
divide = Int::div,
72+
one = 1,
73+
two = 2
74+
)
75+
76+
private fun prefixSumSlower(size: Int, numOfRangesWithMinSize: Int, minSize: Int, possibleMaxSize: Int): Int =
77+
prefixSumSlower(
78+
size = size,
79+
numOfRangesWithMinSize = numOfRangesWithMinSize,
80+
minSize = minSize,
81+
possibleMaxSize = possibleMaxSize,
82+
plus = Int::plus,
83+
minus = Int::minus,
84+
times = Int::times,
85+
divide = Int::div,
86+
mod = Int::rem,
87+
zero = 0,
88+
one = 1,
89+
two = 2
90+
)
91+
92+
private inline fun <NumberT> prefixSumFast(
93+
size: NumberT,
94+
numOfRangesWithMinSize: NumberT,
95+
minSize: NumberT,
96+
possibleMaxSize: NumberT,
97+
crossinline plus: (NumberT, NumberT) -> NumberT,
98+
crossinline minus: (NumberT, NumberT) -> NumberT,
99+
crossinline times: (NumberT, NumberT) -> NumberT,
100+
crossinline divide: (NumberT, NumberT) -> NumberT,
101+
one: NumberT,
102+
two: NumberT,
103+
): NumberT where NumberT : Number, NumberT : Comparable<NumberT> {
104+
val n = plus(minus(size, minSize), one)
105+
val numOfRangesWithGivenSize = numOfRangesWithSize(size, possibleMaxSize, plus, minus, one)
106+
// note, as far as I can see it is not possible that both n and numOfRangesWithMinSize + numOfRangesWithGivenSize
107+
// are odd, i.e. the result is always even, and therefore / 2 is safe (no truncation because of Int/Long arithmetic
108+
// happens)
109+
return divide(times(n, plus(numOfRangesWithMinSize, numOfRangesWithGivenSize)), two)
110+
}
111+
112+
private inline fun <NumberT> prefixSumSlower(
113+
size: NumberT,
114+
numOfRangesWithMinSize: NumberT,
115+
minSize: NumberT,
116+
possibleMaxSize: NumberT,
117+
crossinline plus: (NumberT, NumberT) -> NumberT,
118+
crossinline minus: (NumberT, NumberT) -> NumberT,
119+
crossinline times: (NumberT, NumberT) -> NumberT,
120+
crossinline divide: (NumberT, NumberT) -> NumberT,
121+
crossinline mod: (NumberT, NumberT) -> NumberT,
122+
zero: NumberT,
123+
one: NumberT,
124+
two: NumberT,
125+
): NumberT where NumberT : Number, NumberT : Comparable<NumberT> {
126+
val n = plus(minus(size, minSize), one)
127+
val numOfRangesWithGivenSize = numOfRangesWithSize(size, possibleMaxSize, plus, minus, one)
128+
// usual formula: n * (first + last) / 2 would overflow, hence we divide first. In order not to truncate (due to
129+
// int division) need to check if n is even or not (one of both is always even).
130+
return if (mod(n, two) == zero) {
131+
times(divide(n, two), plus(numOfRangesWithMinSize, numOfRangesWithGivenSize))
132+
} else {
133+
times(n, divide(plus(numOfRangesWithMinSize, numOfRangesWithGivenSize), two))
134+
}
135+
}
136+
137+
private inline fun <NumberT> numOfRangesWithSize(
138+
size: NumberT,
139+
possibleMaxSize: NumberT,
140+
plus: (NumberT, NumberT) -> NumberT,
141+
minus: (NumberT, NumberT) -> NumberT,
142+
one: NumberT,
143+
): NumberT where NumberT : Number, NumberT : Comparable<NumberT> = plus(minus(possibleMaxSize, size), one)

0 commit comments

Comments
 (0)