-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the same as #332 but for `InferMacro`.
- Loading branch information
Showing
5 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
modules/benchmark/src/main/scala/eu/timepit/refined/benchmark/InferMacroBenchmark.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,26 @@ | ||
package eu.timepit.refined.benchmark | ||
|
||
import org.openjdk.jmh.annotations._ | ||
import scala.reflect.runtime.currentMirror | ||
import scala.tools.reflect.ToolBox | ||
|
||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@State(Scope.Thread) | ||
class InferMacroBenchmark { | ||
private val toolBox = | ||
currentMirror.mkToolBox() | ||
|
||
private val autoInfer_Greater_tree = | ||
toolBox.parse(""" | ||
import eu.timepit.refined.W | ||
import eu.timepit.refined.api.Refined | ||
import eu.timepit.refined.auto.autoInfer | ||
import eu.timepit.refined.numeric.Greater | ||
val a: Int Refined Greater[W.`5`.T] = Refined.unsafeApply(10) | ||
val b: Int Refined Greater[W.`0`.T] = a | ||
""") | ||
|
||
@Benchmark | ||
def autoInfer_Greater: Any = | ||
toolBox.eval(autoInfer_Greater_tree) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
### Improvements | ||
|
||
* Avoid calling `eval` in the refine macro for known `RefType` instances. | ||
This reduces compilation times by roughly 26% for all compile-time | ||
refinements. | ||
([#332][#332]) | ||
* Avoid calling `eval` in refine and infer macros for known `RefType` | ||
instances. This reduces compilation times by roughly 26% for all | ||
compile-time refinements with common predicates. | ||
([#332][#332], [#333][#333]) | ||
|
||
[#332]: https://github.com/fthomas/refined/pull/332 | ||
[#333]: https://github.com/fthomas/refined/pull/333 |