michaelbull / kotlin-result

A multiplatform Result monad for modelling success or failure operations.
ISC License
1.02k stars 57 forks source link

Benchmarking [Merge after pr #13] #14

Closed Munzey closed 4 years ago

Munzey commented 4 years ago

This pr also contains the changes introduced in https://github.com/michaelbull/kotlin-result/pull/13

Adds benchmarking via https://github.com/Kotlin/kotlinx-benchmark Under the hood this gradle plugin uses the Java Microbenchmark Harness (JMH) A great guide which describes how to use jmh correctly can be found here: http://tutorials.jenkov.com/java-performance/jmh.html

I'm no expert at this. The benchmark tests themselves that I added are based on the work that @npryce had already done for result4k: https://github.com/npryce/result4k/blob/master/src/jmh/kotlin/com/natpryce/benchmarks.kt

I have added benchmarks for flatmap of this library and result4k, as well as included a benchmark for my proposed binding syntax. There would be nothing stopping someone adding tests for kittinunfs result type, or to compare kotlin's internal result type as well. Or even arrow's Either type if you're curious!

To run, simply call gradle task benchmark. Additional configurations for running bench marks can be specified in build.gradle: https://github.com/Kotlin/kotlinx-benchmark#configuration

michaelbull commented 4 years ago

Added in 0910e9ffe477a1daafbe1dd3fede452f2ae60bca