-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
Xof.Utils
with ability to pass 32 bit numbers (#88)
- Loading branch information
Showing
12 changed files
with
159 additions
and
41 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
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
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
benchmarks/src/commonMain/kotlin/org/kotlincrypto/core/benchmarks/XofOps.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,45 @@ | ||
/* | ||
* Copyright (c) 2025 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.core.benchmarks | ||
|
||
import kotlinx.benchmark.* | ||
import org.kotlincrypto.core.InternalKotlinCryptoApi | ||
import org.kotlincrypto.core.xof.Xof | ||
import kotlin.random.Random | ||
|
||
@State(Scope.Benchmark) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(BenchmarkTimeUnit.NANOSECONDS) | ||
@Warmup(iterations = 5, time = 2) | ||
@Measurement(iterations = 5, time = 3) | ||
@OptIn(InternalKotlinCryptoApi::class) | ||
open class XofUtilsBenchmark { | ||
|
||
private val longs: LongArray = LongArray(10) { Random.Default.nextLong() } | ||
private val loHi = Array(longs.size) { longs[it].let { l -> l.toInt() to l.rotateLeft(32).toInt() } } | ||
|
||
@Benchmark | ||
fun leftEncodeLongs() { | ||
val longs = longs | ||
longs.forEach { long -> Xof.Utils.leftEncode(long) } | ||
} | ||
|
||
@Benchmark | ||
fun leftEncodeLoHi() { | ||
val loHi = loHi | ||
loHi.forEach { Xof.Utils.leftEncode(it.first, it.second) } | ||
} | ||
} |
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
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
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
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,7 +1,6 @@ | ||
module org.kotlincrypto.core.xof { | ||
requires kotlin.stdlib; | ||
requires transitive org.kotlincrypto.core; | ||
requires org.kotlincrypto.endians; | ||
|
||
exports org.kotlincrypto.core.xof; | ||
} |