feat: add Kotlin/Native benchmark for secp256k1 on linuxX64
Mirrors the JVM benchmark (Secp256k1Benchmark.kt) for cross-platform
comparison of the same Kotlin code across runtimes:
K/Native LLVM AOT (-opt) on x86-64:
verifySchnorr: 101,406 ns (9,861 ops/s)
signSchnorr: 80,424 ns (12,434 ops/s)
FieldP.mul: 43 ns (22.8M ops/s)
JVM HotSpot C2 on same machine:
verifySchnorr: 53,600 ns (18,640 ops/s)
signSchnorr: 42,400 ns (23,518 ops/s)
K/N vs JVM: ~1.9× slower (vs C: ~2.9×)
K/N vs C native: ~2.9× slower
Includes field-level micro-benchmarks (FieldP.mul/sqr/add/sub/inv,
unsignedMultiplyHigh, uLt) for isolating LLVM codegen quality.
Also adds -opt to native test compilations for benchmark accuracy
(without it, debug mode is ~12× slower).
Run: ./gradlew :quartz:linuxX64Test --tests "*.Secp256k1NativeBenchmark"
https://claude.ai/code/session_01EMY5RnXb9rnsyU2KbXrSaY
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import com.vanniktech.maven.publish.KotlinMultiplatform
|
||||
import com.vanniktech.maven.publish.SourcesJar
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE
|
||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
||||
|
||||
|
||||
@@ -91,6 +93,16 @@ kotlin {
|
||||
environment("SIMCTL_CHILD_TEST_RESOURCES_ROOT", rootDir)
|
||||
}
|
||||
|
||||
// Enable LLVM optimizations for native test binaries (benchmark accuracy).
|
||||
// Without -opt, K/N test binaries compile in debug mode (~20× slower).
|
||||
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>().configureEach {
|
||||
compilations["test"].compileTaskProvider.configure {
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-opt")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Source set declarations.
|
||||
// Declaring a target automatically creates a source set with the same name. By default, the
|
||||
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
|
||||
|
||||
Reference in New Issue
Block a user