Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed May 27, 2022
1 parent 0b94b10 commit 934862d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
26 changes: 14 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin.Companion.METADATA_TARGET_NAME
import org.jetbrains.kotlin.gradle.targets.js.testing.karma.KotlinKarma
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
import java.io.ByteArrayOutputStream
import java.net.URI

buildscript {
Expand All @@ -12,7 +10,7 @@ buildscript {
}

plugins {
kotlin("multiplatform").version("1.6.20")
kotlin("multiplatform").version("1.6.21")
id("org.jetbrains.kotlinx.benchmark") version "0.4.2"
`maven-publish`
`java-library`
Expand Down Expand Up @@ -43,17 +41,17 @@ kotlin {
}
}
}
js {
js(IR) {
nodejs()
browser {
testTask {
useKarma {
useChromeHeadless()
useChromiumHeadless()
}
}
}
}
//linuxX64()
linuxX64()

targets.all {
if (name != METADATA_TARGET_NAME) compilations.maybeCreate("benchmarks")
Expand Down Expand Up @@ -102,12 +100,12 @@ kotlin {
}
}

// val linuxX64Main by getting {
// dependsOn(commonMain)
// }
// val linuxX64Test by getting {
// dependsOn(linuxX64Main)
// }
val linuxX64Main by getting {
dependsOn(commonMain)
}
val linuxX64Test by getting {
dependsOn(linuxX64Main)
}

val commonBenchmarks by creating {
dependencies {
Expand Down Expand Up @@ -161,6 +159,9 @@ benchmark {
mode = "avgt"
reportFormat = "scsv"
outputTimeUnit = "ns"
iterationTime = 1
iterations = 10
warmups = 8
}
}

Expand All @@ -179,6 +180,7 @@ publishing {
username = deployUsername
password = deployPassword
}

}
}
}
4 changes: 0 additions & 4 deletions src/commonMain/kotlin/ru/spbstu/wheels/Sorts.kt

This file was deleted.

2 changes: 0 additions & 2 deletions src/jsBenchmarks/kotlin/ru/spbstu/wheels/main.kt

This file was deleted.

6 changes: 4 additions & 2 deletions src/jsMain/kotlin/ru/spbstu/wheels/BitsJs.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ru.spbstu.wheels

private val reverseJs = js("""
private object PrivateBits {
val reverseJs = js("""
function(bits) {
var x = new Uint32Array(1); x[0]=bits;
x[0] = ((x[0] & 0x0000ffff) << 16) | ((x[0] & 0xffff0000) >>> 16);
Expand All @@ -11,6 +12,7 @@ private val reverseJs = js("""
return x[0];
}
""")
}

@PublishedApi
internal actual fun Int.reverseBits(): Int = reverseJs(this) as Int
internal actual fun Int.reverseBits(): Int = PrivateBits.reverseJs(this) as Int
15 changes: 14 additions & 1 deletion src/jsMain/kotlin/ru/spbstu/wheels/identityHashCode.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
package ru.spbstu.wheels

actual fun identityHashCode(value: Any?): Int = js("Kotlin.identityHashCode")(value)
private object Identity {
override fun hashCode(): Int {
return super<Any>.hashCode()
}

private val getHashOf = js("function pro(obj) { return Object.getPrototypeOf(obj).hashCode }")
private val identityHashCode = getHashOf(Identity)

fun identityHashCode(value: Any?): Int = identityHashCode.call(value)
}

actual fun identityHashCode(value: Any?): Int {
return Identity.identityHashCode(value)
}
5 changes: 0 additions & 5 deletions src/jsMain/kotlin/ru/spbstu/wheels/sortInJs.kt

This file was deleted.

4 changes: 0 additions & 4 deletions src/jvmMain/kotlin/ru/spbstu/wheels/WeakLazy.kt

This file was deleted.

0 comments on commit 934862d

Please sign in to comment.