-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15268 from dotty-staging/mb/revert-compiletime-op…
…s-covariance Revert #14452 and make compile-time operations on stable arguments stable
- Loading branch information
Showing
15 changed files
with
220 additions
and
102 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
bench-micro/src/main/scala/dotty/tools/benchmarks/TypeOpsBenchmark.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package dotty.tools.benchmarks | ||
|
||
import org.openjdk.jmh.annotations.* | ||
import java.util.concurrent.TimeUnit.SECONDS | ||
import dotty.tools.dotc.{Driver, Run, Compiler} | ||
import dotty.tools.dotc.core.Mode | ||
import dotty.tools.dotc.core.Types.{TermRef, Type} | ||
import dotty.tools.dotc.core.Contexts.{ContextBase, Context, ctx, withMode} | ||
|
||
@Fork(value = 5) | ||
@Warmup(iterations = 5, time = 1, timeUnit = SECONDS) | ||
@Measurement(iterations = 5, time = 1, timeUnit = SECONDS) | ||
@State(Scope.Thread) | ||
class TypeOpsBenchmark: | ||
var tp: Type = null | ||
var context: Context = null | ||
|
||
@Param(Array("int", "singletonsSum", "intsSum", "deepSingletonsSum", "deepIntsSum", "singletonsIntersection", "singletonsUnion")) | ||
var valName: String = "int" | ||
|
||
@Setup(Level.Iteration) | ||
def setup(): Unit = | ||
val driver = new Driver: | ||
override def finish(compiler: Compiler, run: Run)(using Context): Unit = | ||
withMode(Mode.Printing) { | ||
val pkg = run.units(0).tpdTree.symbol | ||
tp = pkg.requiredClass("Test").requiredValueRef(valName).underlying | ||
context = ctx | ||
} | ||
super.finish(compiler, run) | ||
driver.process(Array( | ||
"-classpath", System.getProperty("BENCH_CLASS_PATH"), | ||
"-Ystop-after:typer", | ||
"tests/someTypes.scala" | ||
)) | ||
|
||
@Benchmark | ||
def isStable(): Unit = tp.isStable(using context) | ||
|
||
@Benchmark | ||
def normalized(): Unit = tp.normalized(using context) | ||
|
||
@Benchmark | ||
def simplified(): Unit = tp.simplified(using context) | ||
|
||
@Benchmark | ||
def dealias(): Unit = tp.dealias(using context) | ||
|
||
@Benchmark | ||
def widen(): Unit = tp.widen(using context) | ||
|
||
@Benchmark | ||
def atoms(): Unit = tp.atoms(using context) | ||
|
||
@Benchmark | ||
def isProvisional(): Unit = tp.isProvisional(using context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import compiletime.ops.int.+ | ||
|
||
class Test: | ||
val int: Int = 5 | ||
|
||
val int2: Int = 6 | ||
|
||
val singletonsSum: int.type + int2.type = ??? | ||
|
||
val intsSum: Int + Int = ??? | ||
|
||
val deepSingletonsSum: | ||
((int.type + int2.type) + (int.type + int2.type)) + ((int.type + int2.type) + (int.type + int2.type)) + | ||
((int.type + int2.type) + (int.type + int2.type)) + ((int.type + int2.type) + (int.type + int2.type)) = ??? | ||
|
||
val deepIntsSum: | ||
((Int + Int) + (Int + Int)) + ((Int + Int) + (Int + Int)) + | ||
((Int + Int) + (Int + Int)) + ((Int + Int) + (Int + Int)) = ??? | ||
|
||
val singletonsIntersection: int.type & int2.type = ??? | ||
|
||
val singletonsUnion: int.type | int2.type = ??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.