Skip to content

Commit 8a70f97

Browse files
author
Abduqodiri Qurbonzoda
committed
Add cyclops framework benchmarks
1 parent 67ffd28 commit 8a70f97

Some content is hidden

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

58 files changed

+2221
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/.idea/*
22
!/.idea/copyright
3+
/benchmarks-libraries/.idea/*
4+
!/benchmarks-libraries/.idea/copyright
35
.gradle
46
*.iml
57
target

benchmarks-libraries/.idea/copyright/apache_2_0.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks-libraries/.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benchmarks-libraries/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ compileKotlin {
2323
kotlinOptions.jvmTarget = "1.8"
2424
}
2525

26+
task generateBenchmarkSources(type: JavaExec) {
27+
main = 'generators.BenchmarkSourceGeneratorKt'
28+
classpath = sourceSets.main.runtimeClasspath
29+
}
30+
2631
jmh {
2732
include = ['immutableList', 'immutableMap', 'immutableSet']
2833
exclude = ['builder']
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.cyclops
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(): cyclops.data.Vector<String> {
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[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.cyclops
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 = cyclops.data.Vector.empty<String>()
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[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.cyclops
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 = cyclops.data.Vector.empty<String>()
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.cyclops
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 = cyclops.data.Vector.empty<String>()
35+
36+
@Setup(Level.Trial)
37+
fun prepare() {
38+
persistentList = persistentListAdd(size)
39+
}
40+
41+
@Benchmark
42+
fun removeLast(): cyclops.data.Vector<String> {
43+
var list = persistentList
44+
repeat(times = size) {
45+
list = list.removeAt(list.size - 1)
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.cyclops
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 = cyclops.data.Vector.empty<String>()
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(): cyclops.data.Vector<String> {
45+
repeat(times = size) { index ->
46+
persistentList = persistentList.updateAt(index, "another element")
47+
}
48+
return persistentList
49+
}
50+
51+
@Benchmark
52+
fun setByRandomIndex(): cyclops.data.Vector<String> {
53+
repeat(times = size) { index ->
54+
persistentList = persistentList.updateAt(randomIndices[index], "another element")
55+
}
56+
return persistentList
57+
}
58+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.cyclops
20+
21+
22+
fun persistentListAdd(size: Int): cyclops.data.Vector<String> {
23+
var list = cyclops.data.Vector.empty<String>()
24+
repeat(times = size) {
25+
list = list.plus("some element")
26+
}
27+
return list
28+
}

0 commit comments

Comments
 (0)