All Projects → Kotlin → Kotlinx Benchmark

Kotlin / Kotlinx Benchmark

Licence: apache-2.0
Kotlin multiplatform benchmarking toolkit

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Kotlinx Benchmark

Tyrian
Full-featured TypeScript on JVM
Stars: ✭ 138 (+0.73%)
Mutual labels:  gradle, jvm
Bestnote
👊 持续更新,Java Android 近几年最全面的技术点以及面试题 供自己学习使用
Stars: ✭ 841 (+513.87%)
Mutual labels:  gradle, jvm
stuff
All stuff in a single repo (tests, ideas, benchmarks)
Stars: ✭ 13 (-90.51%)
Mutual labels:  benchmark, jvm
Warren
🐇 Kotlin/JVM, tested, IRC v3.2 client state management and observing
Stars: ✭ 8 (-94.16%)
Mutual labels:  gradle, jvm
Hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications, APIs or queue consumers) that run inside a cloud platform.
Stars: ✭ 336 (+145.26%)
Mutual labels:  gradle, jvm
Android Readthefuckingsourcecode
😜 记录日常的开发技巧,开发中遇到的技术重点、难点,各个知识点的总结,优质面试题等等。持续更新...
Stars: ✭ 1,665 (+1115.33%)
Mutual labels:  gradle, jvm
Jphp
JPHP - an implementation of PHP on Java VM
Stars: ✭ 1,665 (+1115.33%)
Mutual labels:  jvm
Jetson benchmarks
Jetson Benchmark
Stars: ✭ 134 (-2.19%)
Mutual labels:  benchmark
Vtebench
Generate benchmarks for terminal emulators
Stars: ✭ 131 (-4.38%)
Mutual labels:  benchmark
Notes
Including JVM, Java concurrency, Spring framework, Data structure and Algorithm, Computer network, Design pattern, Python, C++, Linux, Mysql, Redis,MATLAB, Git and other tools, etc.
Stars: ✭ 131 (-4.38%)
Mutual labels:  jvm
Xamarin.gradlebindings
VS add-in. Creates Xamarin.Android Binding Projects using gradle
Stars: ✭ 136 (-0.73%)
Mutual labels:  gradle
Kotlin Faker
Generate realistically looking fake data such as names, addresses, banking details, and many more, that can be used for testing and data anonymization purposes.
Stars: ✭ 136 (-0.73%)
Mutual labels:  jvm
Publiccms
现代化java cms,由天津黑核科技有限公司开发,轻松支撑千万数据、千万PV;支持静态化,服务器端包含; 目前已经拥有全球0.0002%的用户,语言支持中、繁、日、英;是一个已走向海外的成熟CMS产品
Stars: ✭ 1,750 (+1177.37%)
Mutual labels:  gradle
Embedded Ai.bench
benchmark for embededded-ai deep learning inference engines, such as NCNN / TNN / MNN / TensorFlow Lite etc.
Stars: ✭ 131 (-4.38%)
Mutual labels:  benchmark
Keeper
A Gradle plugin that infers Proguard/R8 keep rules for androidTest sources.
Stars: ✭ 135 (-1.46%)
Mutual labels:  gradle
Phoenix For Vk
Yet another VK client for Android
Stars: ✭ 131 (-4.38%)
Mutual labels:  gradle
Inspectit Ocelot
inspectIT Ocelot - Java agent for collecting application performance, tracing and behavior data
Stars: ✭ 135 (-1.46%)
Mutual labels:  jvm
Gatling Dubbo
A gatling plugin for running load tests on Apache Dubbo(https://github.com/apache/incubator-dubbo) and other java ecosystem.
Stars: ✭ 131 (-4.38%)
Mutual labels:  benchmark
Xxl Glue
a distributed logical management platform. (分布式逻辑管理平台XXL-GLUE)
Stars: ✭ 133 (-2.92%)
Mutual labels:  jvm
Three.kt
Three.js port for the JVM (desktop)
Stars: ✭ 136 (-0.73%)
Mutual labels:  jvm

JetBrains incubator project GitHub license Build status Maven Central Gradle Plugin Portal

NOTE:   The latest version of the library changes how the plugin and runtime library dependencies are declared:

  • The library runtime is published to Maven Central and no longer published to Bintray.
  • The Gradle plugin is published to Gradle Plugin Portal
  • The Gradle plugin id has changed to org.jetbrains.kotlinx.benchmark
  • The library runtime artifact id has changed to kotlinx-benchmark-runtime

kotlinx.benchmark is a toolkit for running benchmarks for multiplatform code written in Kotlin and running on the next supported targets: JVM, JavaScript.

Technically it can be run on Native target, but current implementation doesn't allow to get right measurements in many cases for native benchmarks, so it isn't recommended to use this library for native benchmarks yet. See issue for more information.

If you're familiar with JMH, it is very similar and uses it under the hoods to run benchmarks on JVM.

Requirements

Gradle 6.8 or newer

Kotlin 1.4.30 or newer

Gradle plugin

Use plugin in build.gradle:

plugins {
    id 'org.jetbrains.kotlinx.benchmark' version '0.3.0'
}

For Kotlin/JS specify building nodejs flavour:

kotlin {
    js {
        nodejs()
        
    }   
}

For Kotlin/JVM code, add allopen plugin to make JMH happy. Alternatively, make all benchmark classes and methods open.

For example, if you annotated each of your benchmark classes with @State(Scope.Benchmark):

@State(Scope.Benchmark)
class Benchmark {
    
}

and added the following code to your build.gradle:

plugins {
    id 'org.jetbrains.kotlin.plugin.allopen'
}

allOpen {
    annotation("org.openjdk.jmh.annotations.State")
}

then you don't have to make benchmark classes and methods open.

Runtime Library

You need a runtime library with annotations and code that will run benchmarks.

Enable Maven Central for dependencies lookup:

repositories {
    mavenCentral()
}

Add the runtime to dependencies of the platform source set, e.g.:

kotlin {
    sourceSets {
        commonMain {
             dependencies {
                 implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.3.0")
             }
        }
    }
}

Configuration

In a build.gradle file create benchmark section, and inside it add a targets section. In this section register all targets you want to run benchmarks from. Example for multiplatform project:

benchmark {
    targets {
        register("jvm") 
        register("js")
        register("native")
    }
}

This package can also be used for Java and Kotlin/JVM projects. Register a Java sourceSet as a target:

benchmark {
    targets {
        register("main") 
    }
}

To configure benchmarks and create multiple profiles, create a configurations section in the benchmark block, and place options inside. Toolkit creates main configuration by default, and you can create as many additional configurations, as you need.

benchmark {
    configurations {
        main { 
            // configure default configuration
        }
        smoke { 
            // create and configure "smoke" configuration, e.g. with several fast benchmarks to quickly check
            // if code changes result in something very wrong, or very right. 
        }       
    }
}

Available configuration options:

  • iterations – number of measuring iterations
  • warmups – number of warm up iterations
  • iterationTime – time to run each iteration (measuring and warmup)
  • iterationTimeUnit – time unit for iterationTime (default is seconds)
  • outputTimeUnit – time unit for results output
  • mode – "thrpt" for measuring operations per time, or "avgt" for measuring time per operation
  • include("…") – regular expression to include benchmarks with fully qualified names matching it, as a substring
  • exclude("…") – regular expression to exclude benchmarks with fully qualified names matching it, as a substring
  • param("name", "value1", "value2") – specify a parameter for a public mutable property name annotated with @Param
  • reportFormat – format of report, can be json(default), csv, scsv or text

Time units can be NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, or their short variants such as "ms" or "ns".

Example:

benchmark {
    // Create configurations
    configurations {
        main { // main configuration is created automatically, but you can change its defaults
            warmups = 20 // number of warmup iterations
            iterations = 10 // number of iterations
            iterationTime = 3 // time in seconds per iteration
        }
        smoke {
            warmups = 5 // number of warmup iterations
            iterations = 3 // number of iterations
            iterationTime = 500 // time in seconds per iteration
            iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
        }   
    }
    
    // Setup targets
    targets {
        // This one matches compilation base name, e.g. 'jvm', 'jvmTest', etc
        register("jvm") {
            jmhVersion = "1.21" // available only for JVM compilations & Java source sets
        }
        register("js") {
            // Note, that benchmarks.js uses a different approach of minTime & maxTime and run benchmarks
            // until results are stable. We estimate minTime as iterationTime and maxTime as iterationTime*iterations
        }
        register("native")
    }
}

Separate source sets for benchmarks

Often you want to have benchmarks in the same project, but separated from main code, much like tests. Here is how:

Define source set:

sourceSets {
    benchmarks
}

Propagate dependencies and output from main sourceSet.

dependencies {
    benchmarksCompile sourceSets.main.output + sourceSets.main.runtimeClasspath 
}

You can also add output and compileClasspath from sourceSets.test in the same way if you want to reuse some of the test infrastructure.

Register benchmarks source set:

benchmark {
    targets {
        register("benchmarks")    
    }
}

Examples

The project contains examples subproject that demonstrates using the library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].