@@ -29,7 +29,7 @@ class Instrumentation extends MiniPhase { thisPhase =>
2929 ctx.settings.YinstrumentAllocations .value
3030
3131 private val namesOfInterest = List (
32- " ::" , " +=" , " toString" ,
32+ " ::" , " +=" , " toString" , " newArray " , " box " ,
3333 " map" , " flatMap" , " filter" , " withFilter" , " collect" , " foldLeft" , " foldRight" , " take" ,
3434 " reverse" , " mapConserve" , " mapconserve" , " filterConserve" , " zip" )
3535 private var namesToRecord : Set [Name ] = _
@@ -46,10 +46,13 @@ class Instrumentation extends MiniPhase { thisPhase =>
4646 ref(defn.Stats_doRecord ).appliedTo(key, Literal (Constant (1 )))
4747 }
4848
49+ private def ok (using Context ) =
50+ ! ctx.owner.ownersIterator.exists(_.name.toString.startsWith(" Stats" ))
51+
4952 override def transformApply (tree : Apply )(using Context ): Tree = tree.fun match {
5053 case Select (nu : New , _) =>
5154 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 =>
5356 cpy.Block (tree)(record(i " call/ ${ref.name}" , tree) :: Nil , tree)
5457 case _ =>
5558 tree
0 commit comments