Skip to content

Commit 86d159b

Browse files
committed
Use uninitialized instead of _ in lazyval benchmarks
1 parent d148973 commit 86d159b

7 files changed

+16
-9
lines changed

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/ContendedInitialization.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -16,12 +17,12 @@ import java.util.concurrent.{Executors, ExecutorService}
1617
class ContendedInitialization {
1718

1819
@Param(Array("2000000", "5000000"))
19-
var size: Int = _
20+
var size: Int = uninitialized
2021

2122
@Param(Array("2", "4", "8"))
22-
var nThreads: Int = _
23+
var nThreads: Int = uninitialized
2324

24-
var executor: ExecutorService = _
25+
var executor: ExecutorService = uninitialized
2526

2627
@Setup
2728
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccess.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccess {
1617

17-
var holder: LazyHolder = _
18+
var holder: LazyHolder = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessAny.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyAnyHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccessAny {
1617

17-
var holder: LazyAnyHolder = _
18+
var holder: LazyAnyHolder = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessGeneric.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyGenericHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccessGeneric {
1617

17-
var holder: LazyGenericHolder[String] = _
18+
var holder: LazyGenericHolder[String] = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessInt.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations.*
45
import org.openjdk.jmh.infra.Blackhole
56
import LazyVals.LazyIntHolder
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccessInt {
1617

17-
var holder: LazyIntHolder = _
18+
var holder: LazyIntHolder = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessMultiple.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccessMultiple {
1617

17-
var holders: Array[LazyHolder] = _
18+
var holders: Array[LazyHolder] = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessString.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.benchmarks.lazyvals
22

3+
import compiletime.uninitialized
34
import org.openjdk.jmh.annotations._
45
import LazyVals.LazyStringHolder
56
import org.openjdk.jmh.infra.Blackhole
@@ -14,7 +15,7 @@ import java.util.concurrent.TimeUnit
1415
@State(Scope.Benchmark)
1516
class InitializedAccessString {
1617

17-
var holder: LazyStringHolder = _
18+
var holder: LazyStringHolder = uninitialized
1819

1920
@Setup
2021
def prepare: Unit = {

0 commit comments

Comments
 (0)