-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
635 additions
and
335 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
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.idea/ | ||
*.iml | ||
local.properties | ||
.kotlin/ |
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
build/ |
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,33 @@ | ||
# benchmarks | ||
|
||
Benchmarks for tracking performance of `sponges` implementation(s). | ||
|
||
**NOTE:** Benchmarking is run on every Pull Request. Results can be viewed for each | ||
workflow run on the [GitHub Actions][url-actions] tab of the repository. | ||
|
||
- Run All platforms: | ||
```shell | ||
./gradlew benchmark | ||
``` | ||
|
||
- Run Jvm: | ||
```shell | ||
./gradlew jvmBenchmark | ||
``` | ||
|
||
- Run Js: | ||
```shell | ||
./gradlew jsBenchmark | ||
``` | ||
|
||
- Run WasmJs: | ||
```shell | ||
./gradlew wasmJsBenchmark | ||
``` | ||
|
||
- Run Native: | ||
```shell | ||
./gradlew nativeHostBenchmark | ||
``` | ||
|
||
[url-actions]: https://github.com/KotlinCrypto/sponges/actions/ |
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,62 @@ | ||
/* | ||
* Copyright (c) 2024 Matthew Nelson | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
import io.matthewnelson.kmp.configuration.extension.container.target.KmpTarget | ||
import kotlinx.benchmark.gradle.BenchmarksExtension | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget | ||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl | ||
import org.jetbrains.kotlin.konan.target.HostManager | ||
import org.jetbrains.kotlin.konan.target.KonanTarget | ||
|
||
plugins { | ||
id("configuration") | ||
} | ||
|
||
kmpConfiguration { | ||
val benchmarks by lazy { extensions.getByType<BenchmarksExtension>() } | ||
|
||
@OptIn(ExperimentalWasmDsl::class) | ||
configure { | ||
fun <T: KotlinTarget> KmpTarget<T>.register() { | ||
target { benchmarks.targets.register(name) } | ||
} | ||
|
||
jvm { register() } | ||
|
||
js { target { browser(); nodejs() }; register() } | ||
wasmJs { target { browser(); nodejs() }; register() } | ||
|
||
val nativeHost = "nativeHost" | ||
when (HostManager.host) { | ||
is KonanTarget.LINUX_X64 -> linuxX64(nativeHost) { register() } | ||
is KonanTarget.LINUX_ARM64 -> linuxArm64(nativeHost) { register() } | ||
is KonanTarget.MACOS_X64 -> macosX64(nativeHost) { register() } | ||
is KonanTarget.MACOS_ARM64 -> macosArm64(nativeHost) { register() } | ||
is KonanTarget.MINGW_X64 -> mingwX64(nativeHost) { register() } | ||
else -> {} | ||
} | ||
|
||
common { | ||
pluginIds(libs.plugins.benchmark.get().pluginId) | ||
|
||
sourceSetMain { | ||
dependencies { | ||
implementation(libs.benchmark.runtime) | ||
implementation(project(":library:keccak")) | ||
} | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
benchmarks/src/commonMain/kotlin/org/kotlincrypto/sponges/benchmarks/KeccakPBenchmark.kt
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,38 @@ | ||
/* | ||
* Copyright (c) 2024 Matthew Nelson | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
package org.kotlincrypto.sponges.benchmarks | ||
|
||
import kotlinx.benchmark.* | ||
import org.kotlincrypto.sponges.keccak.F1600 | ||
import org.kotlincrypto.sponges.keccak.KeccakP | ||
|
||
@State(Scope.Benchmark) | ||
@BenchmarkMode(Mode.Throughput) | ||
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS) | ||
@Warmup(iterations = 5, time = 2) | ||
@Measurement(iterations = 5, time = 4) | ||
open class KeccakPBenchmark { | ||
|
||
private val state = F1600() | ||
|
||
@Setup | ||
fun setup() { | ||
repeat(21) { index -> state.addData(index, (index + 10).toLong()) } | ||
} | ||
|
||
@Benchmark | ||
fun keccakP() { KeccakP(state) } | ||
} |
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 |
---|---|---|
@@ -1,22 +1,25 @@ | ||
[versions] | ||
gradle-benchmark = "0.4.11" | ||
gradle-binary-compat = "0.16.3" | ||
gradle-kmp-configuration = "0.3.2" | ||
gradle-kotlin = "1.9.24" | ||
gradle-publish-maven = "0.29.0" | ||
|
||
# tests | ||
encoding = "2.2.2" | ||
encoding = "2.3.1" | ||
kotlincrypto-endians = "0.3.1" | ||
|
||
[libraries] | ||
gradle-kmp-configuration = { module = "io.matthewnelson:gradle-kmp-configuration-plugin", version.ref = "gradle-kmp-configuration" } | ||
gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "gradle-kotlin" } | ||
gradle-publish-maven = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradle-publish-maven" } | ||
|
||
# tests | ||
# tests & tools | ||
benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "gradle-benchmark" } | ||
encoding-base16 = { module = "io.matthewnelson.encoding:base16", version.ref = "encoding" } | ||
kotlincrypto-endians-endians = { module = "org.kotlincrypto.endians:endians", version.ref = "kotlincrypto-endians" } | ||
|
||
[plugins] | ||
benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "gradle-benchmark" } | ||
binary-compat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "gradle-binary-compat" } | ||
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "gradle-kotlin" } |
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