Skip to content

Commit 12d837b

Browse files
committed
Add tasty Reflect benchmark
This benchmark calls eextractors that use tasty.Reflect internally.
1 parent c908b13 commit 12d837b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.quoted._
2+
3+
object Macro {
4+
5+
extension (inline sc: StringContext):
6+
inline def x(inline args: Int*): String = ${ code('sc, 'args) }
7+
8+
def code(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[String] =
9+
var res: Expr[String] = null
10+
for _ <- 0 to 5_000 do
11+
(strCtxExpr, argsExpr) match {
12+
case ('{ StringContext(${Varargs(Consts(parts))}: _*) }, Varargs(Consts(args))) =>
13+
res = Expr(StringContext(parts: _*).s(args: _*))
14+
case _ => ???
15+
}
16+
res
17+
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Macro._
2+
3+
class Test:
4+
def test: String = x"a${1}b${2}c${3}d${4}e${5}f"

0 commit comments

Comments
 (0)