remove shitty benchmark of coroutines

This commit is contained in:
2026-10-19 13:05:19 +06:00
parent 1f4bb04ec9
commit 651ee37c19
3 changed files with 0 additions and 73 deletions

View File

@@ -1,16 +0,0 @@
plugins {
id "org.jetbrains.kotlin.jvm"
}
repositories {
mavenCentral()
}
dependencies {
api project(":micro_utils.coroutines")
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

View File

@@ -1,56 +0,0 @@
import dev.inmo.micro_utils.coroutines.SmartSemaphore
import dev.inmo.micro_utils.coroutines.withAcquire
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.joinAll
import kotlinx.coroutines.launch
import java.io.File
import kotlin.math.tanh
import kotlin.system.measureNanoTime
data class Record(
val permits: Int,
val i: Int,
val timeNanos: Long
)
private const val permitsCount = 1000
private val acquiresCount = 10000
suspend fun main(args: Array<String>) {
val outputFilePath = args.firstOrNull() ?: "local.bench.txt"
val records = ArrayList<Record>(permitsCount * acquiresCount)
val jobs = ArrayList<Job>()
val scope = CoroutineScope(Dispatchers.Default)
for (permits in 1 .. permitsCount) {
val semaphore = SmartSemaphore.Mutable(permits)
for (i in 0 until acquiresCount) {
jobs.add(
scope.launch(start = CoroutineStart.LAZY) {
val timeNanos = measureNanoTime {
semaphore.withAcquire {
tanh(57.179)
}
}
records.add(Record(permits, i, timeNanos))
}
)
}
}
jobs.joinAll()
val file = File(outputFilePath)
file.writeText("")
val text = buildString {
records.groupBy { it.permits }.forEach {
it.value.sortedBy { it.i }.forEach {
append("${it.permits} ${it.i} ${it.timeNanos}\n")
}
}
}
file.appendText(text)
file.appendText("\n")
println(text)
}

View File

@@ -35,7 +35,6 @@ String[] includes = [
":ktor:client",
":coroutines",
":coroutines:compose",
":coroutines:benchmark",
":android:recyclerview",
":android:pickers",
":android:smalltextfield",