|
| 1 | +plugins { |
| 2 | + id("org.jetbrains.kotlin.jvm") |
| 3 | +} |
| 4 | + |
| 5 | +dependencies { |
| 6 | + implementation("org.jetbrains.kotlin:kotlin-stdlib") |
| 7 | + implementation("org.openjdk.jmh:jmh-core:1.21") |
| 8 | + |
| 9 | + runtimeOnly(project(path = ":benchmarks", configuration = "benchmarksJar")) |
| 10 | + runtimeOnly(project(":kotlinx-collections-immutable")) |
| 11 | +} |
| 12 | + |
| 13 | +sourceSets.main { |
| 14 | + kotlin.srcDirs("src") |
| 15 | +} |
| 16 | + |
| 17 | +// map |
| 18 | +val benchmarkHashMap by tasks.registering(JavaExec::class) { |
| 19 | + group = "Benchmark" |
| 20 | + mainClass.set("runners.HashMapRunnerKt") |
| 21 | +} |
| 22 | + |
| 23 | +val benchmarkHashMapBuilder by tasks.registering(JavaExec::class) { |
| 24 | + group = "Benchmark" |
| 25 | + mainClass.set("runners.HashMapBuilderRunnerKt") |
| 26 | +} |
| 27 | + |
| 28 | +val benchmarkOrderedMap by tasks.registering(JavaExec::class) { |
| 29 | + group = "Benchmark" |
| 30 | + mainClass.set("runners.OrderedMapRunnerKt") |
| 31 | +} |
| 32 | + |
| 33 | +val benchmarkOrderedMapBuilder by tasks.registering(JavaExec::class) { |
| 34 | + group = "Benchmark" |
| 35 | + mainClass.set("runners.OrderedMapBuilderRunnerKt") |
| 36 | +} |
| 37 | + |
| 38 | +val benchmarkAllMaps by tasks.registering { |
| 39 | + group = "Benchmark" |
| 40 | + dependsOn(benchmarkHashMap) |
| 41 | + dependsOn(benchmarkHashMapBuilder) |
| 42 | + dependsOn(benchmarkOrderedMap) |
| 43 | + dependsOn(benchmarkOrderedMapBuilder) |
| 44 | +} |
| 45 | + |
| 46 | +// set |
| 47 | +val benchmarkHashSet by tasks.registering(JavaExec::class) { |
| 48 | + group = "Benchmark" |
| 49 | + mainClass.set("runners.HashSetRunnerKt") |
| 50 | +} |
| 51 | + |
| 52 | +val benchmarkHashSetBuilder by tasks.registering(JavaExec::class) { |
| 53 | + group = "Benchmark" |
| 54 | + mainClass.set("runners.HashSetBuilderRunnerKt") |
| 55 | +} |
| 56 | + |
| 57 | +val benchmarkOrderedSet by tasks.registering(JavaExec::class) { |
| 58 | + group = "Benchmark" |
| 59 | + mainClass.set("runners.OrderedSetRunnerKt") |
| 60 | +} |
| 61 | + |
| 62 | +val benchmarkOrderedSetBuilder by tasks.registering(JavaExec::class) { |
| 63 | + group = "Benchmark" |
| 64 | + mainClass.set("runners.OrderedSetBuilderRunnerKt") |
| 65 | +} |
| 66 | + |
| 67 | +val benchmarkAllSets by tasks.registering { |
| 68 | + group = "Benchmark" |
| 69 | + dependsOn(benchmarkHashSet) |
| 70 | + dependsOn(benchmarkHashSetBuilder) |
| 71 | + dependsOn(benchmarkOrderedSet) |
| 72 | + dependsOn(benchmarkOrderedSetBuilder) |
| 73 | +} |
| 74 | + |
| 75 | +// list |
| 76 | +val benchmarkList by tasks.registering(JavaExec::class) { |
| 77 | + group = "Benchmark" |
| 78 | + mainClass.set("runners.ListRunnerKt") |
| 79 | +} |
| 80 | + |
| 81 | +val benchmarkListBuilder by tasks.registering(JavaExec::class) { |
| 82 | + group = "Benchmark" |
| 83 | + mainClass.set("runners.ListBuilderRunnerKt") |
| 84 | +} |
| 85 | + |
| 86 | +val benchmarkAllLists by tasks.registering { |
| 87 | + group = "Benchmark" |
| 88 | + dependsOn(benchmarkList) |
| 89 | + dependsOn(benchmarkListBuilder) |
| 90 | +} |
| 91 | + |
| 92 | +// all |
| 93 | +val benchmarkAll by tasks.registering { |
| 94 | + group = "Benchmark" |
| 95 | + dependsOn(benchmarkAllMaps) |
| 96 | + dependsOn(benchmarkAllSets) |
| 97 | + dependsOn(benchmarkAllLists) |
| 98 | +} |
| 99 | + |
| 100 | +// configure runner tasks |
| 101 | + |
| 102 | +val benchmarkParams = listOf( |
| 103 | + "remote", |
| 104 | + "forks", |
| 105 | + "measurementIterations", |
| 106 | + "measurementTime", |
| 107 | + "warmupIterations", |
| 108 | + "warmupTime", |
| 109 | +// "exclude", |
| 110 | +// "include", |
| 111 | + "size", |
| 112 | + "hashCodeType", |
| 113 | + "immutablePercentage" |
| 114 | +) |
| 115 | + |
| 116 | +tasks.withType<JavaExec>().configureEach { |
| 117 | + if (group == "Benchmark") { |
| 118 | + classpath = sourceSets.main.get().runtimeClasspath |
| 119 | + |
| 120 | + benchmarkParams.forEach { param -> |
| 121 | + if (project.hasProperty(param)) { |
| 122 | + systemProperty(param, requireNotNull(project.property(param))) |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | +} |
0 commit comments