Skip to content

Commit c271ac9

Browse files
author
Abduqodiri Qurbonzoda
committed
Add clojure, scala and vavr benchmarks
1 parent 8a70f97 commit c271ac9

File tree

216 files changed

+6497
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+6497
-203
lines changed

benchmarks-libraries/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ dependencies {
1717
implementation 'io.usethesource:capsule:0.6.1'
1818
implementation 'org.organicdesign:Paguro:3.1.2'
1919
implementation 'com.oath.cyclops:cyclops:10.3.0'
20+
implementation 'org.clojure:clojure:1.10.0'
21+
implementation 'org.scala-lang:scala-library:2.13.0'
22+
implementation 'io.vavr:vavr:0.9.3'
2023
}
2124

2225
compileKotlin {
2326
kotlinOptions.jvmTarget = "1.8"
2427
}
2528

29+
compileJmhKotlin {
30+
kotlinOptions.jvmTarget = "1.8"
31+
}
32+
2633
task generateBenchmarkSources(type: JavaExec) {
2734
main = 'generators.BenchmarkSourceGeneratorKt'
2835
classpath = sourceSets.main.runtimeClasspath
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
import org.openjdk.jmh.infra.Blackhole
24+
25+
@Fork(1)
26+
@Warmup(iterations = 5)
27+
@Measurement(iterations = 5)
28+
@BenchmarkMode(Mode.AverageTime)
29+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
30+
@State(Scope.Thread)
31+
open class Add {
32+
@Param("10000", "100000")
33+
var size: Int = 0
34+
35+
@Benchmark
36+
fun addLast(): clojure.lang.PersistentVector {
37+
return persistentListAdd(size)
38+
}
39+
40+
@Benchmark
41+
fun addLastAndIterate(bh: Blackhole) {
42+
val list = persistentListAdd(size)
43+
for (e in list) {
44+
bh.consume(e)
45+
}
46+
}
47+
48+
@Benchmark
49+
fun addLastAndGet(bh: Blackhole) {
50+
val list = persistentListAdd(size)
51+
for (i in 0 until size) {
52+
bh.consume(list.get(i))
53+
}
54+
}
55+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
import org.openjdk.jmh.infra.Blackhole
24+
25+
@Fork(1)
26+
@Warmup(iterations = 5)
27+
@Measurement(iterations = 5)
28+
@BenchmarkMode(Mode.AverageTime)
29+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
30+
@State(Scope.Thread)
31+
open class Get {
32+
@Param("10000", "100000")
33+
var size: Int = 0
34+
35+
private var persistentList = clojure.lang.PersistentVector.EMPTY
36+
37+
@Setup(Level.Trial)
38+
fun prepare() {
39+
persistentList = persistentListAdd(size)
40+
}
41+
42+
@Benchmark
43+
fun getByIndex(bh: Blackhole) {
44+
for (i in 0 until size) {
45+
bh.consume(persistentList.get(i))
46+
}
47+
}
48+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
import org.openjdk.jmh.infra.Blackhole
24+
25+
@Fork(1)
26+
@Warmup(iterations = 5)
27+
@Measurement(iterations = 5)
28+
@BenchmarkMode(Mode.AverageTime)
29+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
30+
@State(Scope.Thread)
31+
open class Iterate {
32+
@Param("10000", "100000")
33+
var size: Int = 0
34+
35+
private var persistentList = clojure.lang.PersistentVector.EMPTY
36+
37+
@Setup(Level.Trial)
38+
fun prepare() {
39+
persistentList = persistentListAdd(size)
40+
}
41+
42+
@Benchmark
43+
fun firstToLast(bh: Blackhole) {
44+
for (e in persistentList) {
45+
bh.consume(e)
46+
}
47+
}
48+
49+
@Benchmark
50+
fun lastToFirst(bh: Blackhole) {
51+
val iterator = persistentList.listIterator(size)
52+
53+
while (iterator.hasPrevious()) {
54+
bh.consume(iterator.previous())
55+
}
56+
}
57+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
24+
@Fork(1)
25+
@Warmup(iterations = 5)
26+
@Measurement(iterations = 5)
27+
@BenchmarkMode(Mode.AverageTime)
28+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
29+
@State(Scope.Thread)
30+
open class Remove {
31+
@Param("10000", "100000")
32+
var size: Int = 0
33+
34+
private var persistentList = clojure.lang.PersistentVector.EMPTY
35+
36+
@Setup(Level.Trial)
37+
fun prepare() {
38+
persistentList = persistentListAdd(size)
39+
}
40+
41+
@Benchmark
42+
fun removeLast(): clojure.lang.PersistentVector {
43+
var list = persistentList
44+
repeat(times = size) {
45+
list = list.pop()
46+
}
47+
return list
48+
}
49+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
24+
@Fork(1)
25+
@Warmup(iterations = 5)
26+
@Measurement(iterations = 5)
27+
@BenchmarkMode(Mode.AverageTime)
28+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
29+
@State(Scope.Thread)
30+
open class Set {
31+
@Param("10000", "100000")
32+
var size: Int = 0
33+
34+
private var persistentList = clojure.lang.PersistentVector.EMPTY
35+
private var randomIndices = listOf<Int>()
36+
37+
@Setup(Level.Trial)
38+
fun prepare() {
39+
persistentList = persistentListAdd(size)
40+
randomIndices = List(size) { it }.shuffled()
41+
}
42+
43+
@Benchmark
44+
fun setByIndex(): clojure.lang.PersistentVector {
45+
repeat(times = size) { index ->
46+
persistentList = persistentList.assocN(index, "another element")
47+
}
48+
return persistentList
49+
}
50+
51+
@Benchmark
52+
fun setByRandomIndex(): clojure.lang.PersistentVector {
53+
repeat(times = size) { index ->
54+
persistentList = persistentList.assocN(randomIndices[index], "another element")
55+
}
56+
return persistentList
57+
}
58+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure.builder
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
import org.openjdk.jmh.infra.Blackhole
24+
25+
@Fork(1)
26+
@Warmup(iterations = 5)
27+
@Measurement(iterations = 5)
28+
@BenchmarkMode(Mode.AverageTime)
29+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
30+
@State(Scope.Thread)
31+
open class Add {
32+
@Param("10000", "100000")
33+
var size: Int = 0
34+
35+
@Param("0.0", "50.0")
36+
var immutablePercentage: Double = 0.0
37+
38+
@Benchmark
39+
fun addLast(): clojure.lang.ITransientVector {
40+
return persistentListBuilderAdd(size, immutablePercentage)
41+
}
42+
43+
@Benchmark
44+
fun addLastAndGet(bh: Blackhole) {
45+
val builder = persistentListBuilderAdd(size, immutablePercentage)
46+
for (i in 0 until size) {
47+
bh.consume(builder.valAt(i))
48+
}
49+
}
50+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Auto-generated file. DO NOT EDIT!
18+
19+
package benchmarks.immutableList.clojure.builder
20+
21+
import org.openjdk.jmh.annotations.*
22+
import java.util.concurrent.TimeUnit
23+
import org.openjdk.jmh.infra.Blackhole
24+
25+
@Fork(1)
26+
@Warmup(iterations = 5)
27+
@Measurement(iterations = 5)
28+
@BenchmarkMode(Mode.AverageTime)
29+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
30+
@State(Scope.Thread)
31+
open class Get {
32+
@Param("10000", "100000")
33+
var size: Int = 0
34+
35+
@Param("0.0", "50.0")
36+
var immutablePercentage: Double = 0.0
37+
38+
private var builder: clojure.lang.ITransientVector = clojure.lang.PersistentVector.EMPTY.asTransient() as clojure.lang.ITransientVector
39+
40+
@Setup(Level.Trial)
41+
fun prepare() {
42+
builder = persistentListBuilderAdd(size, immutablePercentage)
43+
}
44+
45+
@Benchmark
46+
fun getByIndex(bh: Blackhole) {
47+
for (i in 0 until size) {
48+
bh.consume(builder.valAt(i))
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)