Skip to content

Commit

Permalink
Feature/benchmark (#32)
Browse files Browse the repository at this point in the history
* Update Gradle

* Fix published

* Update libraries

* Fix inheritances issue

* Add Kover

* Add benchmark

* Increase version

* Fix test action
  • Loading branch information
Scogun authored May 15, 2024
1 parent ddbaee8 commit 5f97b40
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Decode GPG Key
run: |
echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" > ~/.gradle/secring.gpg.b64
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
base64 --decode -i ~/.gradle/secring.gpg.b64 -o ~/.gradle/secring.gpg
shell: bash

- name: Publish
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build-and-test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-13, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
run: ./gradlew cleanMingwX64Test mingwX64Test --tests "com.ucasoft.kcron.*"

- name: "Tests"
if: ${{ matrix.os == 'macos-latest' }}
if: ${{ matrix.os == 'macos-13' }}
run: ./gradlew cleanMacosX64Test macosX64Test --tests "com.ucasoft.kcron.*"

- name: "Tests Report"
Expand All @@ -50,3 +50,19 @@ jobs:
name: jUnit Tests
path: '**/build/test-results/*Test/TEST-*.xml'
reporter: java-junit

- name: "Run Coverage"
if: ${{ github.event_name == 'pull_request' }}
run: ./gradlew koverXmlReport
shell: bash

- name: "Coverage Report"
uses: mi-kas/kover-report@v1
if: ${{ github.event_name == 'pull_request' }}
with:
path: |
./kcron-common/build/reports/kover/report.xml
./kcron-core/build/reports/kover/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: "Coverage Report"
update-comment: true
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# KCron
Cron realization for Kotlin Multiplatform

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Scogun_kcron-common&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Scogun_kcron-common) ![GitHub](https://img.shields.io/github/license/Scogun/kcron-common?color=blue) ![Publish workflow](https://github.com/Scogun/kcron-common/actions/workflows/publish.yml/badge.svg) [![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.kcron/kcron-common/0.10.5?color=blue)](https://search.maven.org/artifact/com.ucasoft.kcron/kcron-common/0.10.5/jar)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Scogun_kcron-common&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Scogun_kcron-common) ![GitHub](https://img.shields.io/github/license/Scogun/kcron-common?color=blue) ![Publish workflow](https://github.com/Scogun/kcron-common/actions/workflows/publish.yml/badge.svg) [![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.kcron/kcron-common/0.13.2?color=blue)](https://search.maven.org/artifact/com.ucasoft.kcron/kcron-common/0.13.2/jar)

### Features
* Kotlin Multiplatform library
Expand Down Expand Up @@ -50,7 +50,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation 'com.ucasoft.kcron:kcron-common:0.10.5'
implementation 'com.ucasoft.kcron:kcron-common:0.13.2'
}
}
}
Expand Down Expand Up @@ -115,6 +115,6 @@ builder.years(2021..2025)
println(builder.expression) // 0/10 5-25 5,12 ? * SUN#5 2021-2025
```
### Current status
This library is on beta version `0.10.5`.
This library is on beta version `0.13.2`.
It is continuing to develop.
Check the news!
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ allprojects {

group = "com.ucasoft.kcron"

version = "0.10.5"
version = "0.13.2"

repositories {
mavenCentral()
Expand Down
11 changes: 8 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[versions]
kotlin = "1.9.23"
kotlinx-datetime = "0.5.0"
kotest = "5.8.1"
kotlinx-datetime = "0.6.0"
kotest = "5.9.0"
kover = "0.7.6"
benchmark = "0.4.10"

[libraries]
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
kotlinx-benchmark = { group = "org.jetbrains.kotlinx", name = "kotlinx-benchmark-runtime", version.ref = "benchmark" }
kotest-assetions = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }


[plugins]
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "benchmark" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 2 additions & 0 deletions kcron-abstractions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
alias(libs.plugins.kover) apply false
alias(libs.plugins.benchmark) apply false
}

kotlin {
Expand Down
38 changes: 38 additions & 0 deletions kcron-common-benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
alias(libs.plugins.multiplatform)
alias(libs.plugins.benchmark)
alias(libs.plugins.kover) apply false
}

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
linuxX64()
mingwX64()
macosX64()
js(IR) {
browser()
nodejs()
}
sourceSets {
commonMain {
dependencies {
implementation(project(":kcron-common"))
implementation(libs.kotlinx.benchmark)
}
}
}
}

benchmark {
targets {
register("jvm")
register("js")
register("linuxX64")
register("mingwX64")
register("macosX64")
}
}
32 changes: 32 additions & 0 deletions kcron-common-benchmark/src/commonMain/kotlin/Iterate.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package benchmarks.builder

import com.ucasoft.kcron.Cron
import com.ucasoft.kcron.core.builders.DelicateIterableApi
import com.ucasoft.kcron.core.extensions.years
import kotlinx.benchmark.*

@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(BenchmarkTimeUnit.MICROSECONDS)
@Warmup(iterations = 2)
@State(Scope.Benchmark)
open class Iterate {

@Param("1", "10", "100", "1000", "10000")
var take = 1

private val builder = Cron.builder()

@Setup
fun prepare() {
builder
.years(2050..2055)
}

@OptIn(DelicateIterableApi::class)
@Benchmark
fun iterate(bh: Blackhole) {
for (date in builder.asIterable().take(take)) {
bh.consume(date)
}
}
}
6 changes: 4 additions & 2 deletions kcron-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
alias(libs.plugins.kover)
alias(libs.plugins.benchmark) apply false
}

kotlin {
Expand All @@ -24,8 +26,8 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":kcron-core"))
implementation(project(":kcron-kotlinx-datetime"))
api(project(":kcron-core"))
api(project(":kcron-kotlinx-datetime"))
}
}
commonTest {
Expand Down
2 changes: 2 additions & 0 deletions kcron-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
alias(libs.plugins.kover)
alias(libs.plugins.benchmark) apply false
}

kotlin {
Expand Down
2 changes: 2 additions & 0 deletions kcron-kotlinx-datetime/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
alias(libs.plugins.kover) apply false
alias(libs.plugins.benchmark) apply false
}

kotlin {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rootProject.name = "kcron"
include(
"kcron-abstractions",
"kcron-common",
"kcron-common-benchmark",
"kcron-core",
"kcron-kotlinx-datetime"
)

0 comments on commit 5f97b40

Please sign in to comment.