/
ClasspathSymbolsBench.scala
52 lines (44 loc) 路 1.39 KB
/
ClasspathSymbolsBench.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package bench
import java.util.concurrent.TimeUnit
import scala.meta.dialects
import scala.meta.internal.metals.BuildTargets
import scala.meta.internal.metals.EmptyReportContext
import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.tvp.IndexedSymbols
import scala.meta.io.AbsolutePath
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Mode
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.Setup
import org.openjdk.jmh.annotations.State
import org.openjdk.jmh.annotations.TearDown
import tests.Library
import tests.TreeUtils
@State(Scope.Benchmark)
class ClasspathSymbolsBench {
var classpath: Seq[AbsolutePath] = _
@Setup
def setup(): Unit = {
classpath = Library.catsSources.filter(_.filename.contains("sources"))
}
@TearDown
def teardown(): Unit = {}
@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
def run(): Unit = {
implicit val reporting = EmptyReportContext
val (buffers, trees) = TreeUtils.getTrees(scalaVersion = None)
val jars = new IndexedSymbols(
isStatisticsEnabled = false,
trees,
buffers,
BuildTargets.empty,
)
classpath.foreach { jar =>
jars.jarSymbols(jar, "cats/", dialects.Scala213)
}
}
}