@@ -29,7 +29,7 @@ class Instrumentation extends MiniPhase { thisPhase =>
29
29
ctx.settings.YinstrumentAllocations .value
30
30
31
31
private val namesOfInterest = List (
32
- " ::" , " +=" , " toString" ,
32
+ " ::" , " +=" , " toString" , " newArray " , " box " ,
33
33
" map" , " flatMap" , " filter" , " withFilter" , " collect" , " foldLeft" , " foldRight" , " take" ,
34
34
" reverse" , " mapConserve" , " mapconserve" , " filterConserve" , " zip" )
35
35
private var namesToRecord : Set [Name ] = _
@@ -46,10 +46,13 @@ class Instrumentation extends MiniPhase { thisPhase =>
46
46
ref(defn.Stats_doRecord ).appliedTo(key, Literal (Constant (1 )))
47
47
}
48
48
49
+ private def ok (using Context ) =
50
+ ! ctx.owner.ownersIterator.exists(_.name.toString.startsWith(" Stats" ))
51
+
49
52
override def transformApply (tree : Apply )(using Context ): Tree = tree.fun match {
50
53
case Select (nu : New , _) =>
51
54
cpy.Block (tree)(record(i " alloc/ ${nu.tpe}" , tree) :: Nil , tree)
52
- case ref : RefTree if namesToRecord.contains(ref.name) =>
55
+ case ref : RefTree if namesToRecord.contains(ref.name) && ok =>
53
56
cpy.Block (tree)(record(i " call/ ${ref.name}" , tree) :: Nil , tree)
54
57
case _ =>
55
58
tree
0 commit comments