@@ -10,12 +10,13 @@ package nsc
10
10
import java .io .{File , FileNotFoundException , IOException }
11
11
import java .net .URL
12
12
import java .nio .charset .{Charset , CharsetDecoder , IllegalCharsetNameException , UnsupportedCharsetException }
13
+
13
14
import scala .collection .{immutable , mutable }
14
15
import io .{AbstractFile , Path , SourceReader }
15
16
import reporters .Reporter
16
17
import util .{ClassPath , returning }
17
18
import scala .reflect .ClassTag
18
- import scala .reflect .internal .util .{BatchSourceFile , NoSourceFile , ScalaClassLoader , ScriptSourceFile , SourceFile , StatisticsStatics }
19
+ import scala .reflect .internal .util .{BatchSourceFile , NoSourceFile , ScalaClassLoader , ScriptSourceFile , SourceFile , Statistics , StatisticsStatics }
19
20
import scala .reflect .internal .pickling .PickleBuffer
20
21
import symtab .{Flags , SymbolTable , SymbolTrackers }
21
22
import symtab .classfile .Pickler
@@ -26,9 +27,11 @@ import typechecker._
26
27
import transform .patmat .PatternMatching
27
28
import transform ._
28
29
import backend .{JavaPlatform , ScalaPrimitives }
29
- import backend .jvm .{GenBCode , BackendStats }
30
+ import backend .jvm .{BackendStats , GenBCode }
31
+ import scala .collection .mutable .ArrayBuffer
30
32
import scala .concurrent .Future
31
33
import scala .language .postfixOps
34
+ import scala .reflect .io .Path
32
35
import scala .tools .nsc .ast .{TreeGen => AstTreeGen }
33
36
import scala .tools .nsc .classpath ._
34
37
import scala .tools .nsc .profile .Profiler
@@ -1477,8 +1480,41 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
1477
1480
runCheckers()
1478
1481
1479
1482
// output collected statistics
1480
- if (settings.YstatisticsEnabled && settings.Ystatistics .contains(phase.name))
1483
+ if (settings.YstatisticsEnabled && settings.Ystatistics .contains(phase.name)) {
1481
1484
printStatisticsFor(phase)
1485
+ if (phase == typerPhase) {
1486
+ import java .nio .file ._
1487
+ val writer = Files .newBufferedWriter(java.nio.file.Paths .get(" /tmp/output.csv" ))
1488
+ try {
1489
+ for ((key @ statistics.StatsKey (sym, macroo, implicitPt), stats) <- statistics.statsMap if sym != NoSymbol ) {
1490
+ val ownerChain = sym.ownerChain.toArray
1491
+ var i = ownerChain.length - 1
1492
+ while (i >= 0 ) {
1493
+ writer.write(ownerChain(i).name.toString)
1494
+ if (i != 0 ) writer.write(" ;" )
1495
+ i -= 1
1496
+ }
1497
+ if (macroo != NoSymbol ) {
1498
+ writer.write(" ;" )
1499
+ writer.write(" <macro>;" )
1500
+ writer.write(macroo.fullName)
1501
+ }
1502
+ if (implicitPt != NoSymbol ) {
1503
+ writer.write(" ;" )
1504
+ writer.write(" <implicit>;" )
1505
+ writer.write(implicitPt.fullName)
1506
+ }
1507
+ writer.write(" " )
1508
+ writer.write(String .valueOf(stats.duration))
1509
+ writer.write(" \n " )
1510
+ }
1511
+ } finally {
1512
+ writer.close()
1513
+ }
1514
+ }
1515
+ }
1516
+
1517
+
1482
1518
1483
1519
advancePhase()
1484
1520
}
@@ -1580,9 +1616,8 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
1580
1616
private val hotCounters =
1581
1617
List (statistics.retainedCount, statistics.retainedByType, statistics.nodeByType)
1582
1618
private val parserStats = {
1583
- import statistics .treeNodeCount
1584
- if (settings.YhotStatisticsEnabled ) treeNodeCount :: hotCounters
1585
- else List (treeNodeCount)
1619
+ if (settings.YhotStatisticsEnabled ) statistics.treeNodeCount :: hotCounters
1620
+ else List (statistics.treeNodeCount)
1586
1621
}
1587
1622
1588
1623
final def printStatisticsFor (phase : Phase ) = {
@@ -1599,7 +1634,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
1599
1634
}
1600
1635
}
1601
1636
1602
- val quants : Iterable [statistics. Quantity ] =
1637
+ val quants : Iterable [Statistics # Quantity ] =
1603
1638
if (phase.name == " parser" ) parserStats
1604
1639
else if (settings.YhotStatisticsEnabled ) statistics.allQuantities
1605
1640
else statistics.allQuantities.filterNot(q => hotCounters.contains(q))
0 commit comments