File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed
runtime/nativeMain/src/kotlinx/benchmark Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change 1
1
package kotlinx.benchmark
2
2
3
+ import kotlinx.cinterop.pin
4
+
5
+
3
6
actual class Blackhole {
4
- @ThreadLocal
5
- companion object {
6
- var consumer = 0
7
- }
8
7
actual fun consume (obj : Any? ) {
9
- // hashCode now is implemented as taking address of object, so it's suitable now.
10
- // If implementation is changed `Blackhole` should be reimplemented.
11
- consumer + = obj.hashCode()
8
+ obj?.pin()
12
9
}
13
10
actual fun consume (bool : Boolean ) {
14
- consumer + = bool.hashCode ()
11
+ bool.pin ()
15
12
}
16
13
actual fun consume (c : Char ) {
17
- consumer + = c.hashCode ()
14
+ c.pin ()
18
15
}
19
16
actual fun consume (b : Byte ) {
20
- consumer + = b.hashCode ()
17
+ b.pin ()
21
18
}
22
19
actual fun consume (s : Short ) {
23
- consumer + = s.hashCode ()
20
+ s.pin ()
24
21
}
25
22
actual fun consume (i : Int ) {
26
- consumer + = i.hashCode ()
23
+ i.pin ()
27
24
}
28
25
actual fun consume (l : Long ) {
29
- consumer + = l.hashCode ()
26
+ l.pin ()
30
27
}
31
28
actual fun consume (f : Float ) {
32
- consumer + = f.hashCode ()
29
+ f.pin ()
33
30
}
34
31
actual fun consume (d : Double ) {
35
- consumer + = d.hashCode ()
32
+ d.pin ()
36
33
}
37
- }
34
+ }
You can’t perform that action at this time.
0 commit comments