@@ -32,7 +32,7 @@ case class ProfileSnap(threadId: Long, threadName: String, snapTimeNanos : Long,
32
32
copy(heapBytes = heapBytes)
33
33
}
34
34
}
35
- case class ProfileRange (start : ProfileSnap , end: ProfileSnap , phase: Phase , id : Int , purpose : String , thread: Thread ) {
35
+ case class ProfileRange (start : ProfileSnap , end: ProfileSnap , phase: Phase , purpose : String , taskCount : Int , thread: Thread ) {
36
36
def allocatedBytes = end.allocatedBytes - start.allocatedBytes
37
37
38
38
def userNs = end.userTimeNanos - start.userTimeNanos
@@ -105,15 +105,15 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(implicit ctx: C
105
105
106
106
private val mainThread = Thread .currentThread()
107
107
108
- private [profile] def snapThread (): ProfileSnap = {
108
+ private [profile] def snapThread (idleTimeNanos : Long ): ProfileSnap = {
109
109
import RealProfiler ._
110
110
val current = Thread .currentThread()
111
111
112
112
ProfileSnap (
113
113
threadId = current.getId,
114
114
threadName = current.getName,
115
115
snapTimeNanos = System .nanoTime(),
116
- idleTimeNanos = 0 ,
116
+ idleTimeNanos = idleTimeNanos ,
117
117
cpuTimeNanos = threadMx.getCurrentThreadCpuTime,
118
118
userTimeNanos = threadMx.getCurrentThreadUserTime,
119
119
allocatedBytes = threadMx.getThreadAllocatedBytes(Thread .currentThread().getId),
@@ -158,13 +158,13 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(implicit ctx: C
158
158
val startTime = info.get(" startTime" ).asInstanceOf [jLong].longValue()
159
159
val endTime = info.get(" endTime" ).asInstanceOf [jLong].longValue()
160
160
val threads = info.get(" GcThreadCount" ).asInstanceOf [jInt].longValue()
161
- reporter.reportGc(new GcEventData (" " , reportNs, startTime, endTime, name, action, cause, threads))
161
+ reporter.reportGc(GcEventData (" " , reportNs, startTime, endTime, name, action, cause, threads))
162
162
}
163
163
}
164
164
165
165
override def afterPhase (phase : Phase , snapBefore : ProfileSnap ): Unit = {
166
166
assert(mainThread eq Thread .currentThread())
167
- val initialSnap = snapThread()
167
+ val initialSnap = snapThread(0 )
168
168
if (ctx.settings.YprofileExternalTool .value.contains(phase.toString)) {
169
169
println(" Profile hook stop" )
170
170
ExternalToolHook .after()
@@ -174,7 +174,7 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(implicit ctx: C
174
174
initialSnap.updateHeap(readHeapUsage())
175
175
} else initialSnap
176
176
177
- reporter.reportForeground(this , new ProfileRange (snapBefore, finalSnap, phase, id, " " , Thread .currentThread))
177
+ reporter.reportForeground(this , ProfileRange (snapBefore, finalSnap, phase, " " , 0 , Thread .currentThread))
178
178
}
179
179
180
180
override def beforePhase (phase : Phase ): ProfileSnap = {
@@ -185,7 +185,7 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(implicit ctx: C
185
185
println(" Profile hook start" )
186
186
ExternalToolHook .before()
187
187
}
188
- snapThread()
188
+ snapThread(0 )
189
189
}
190
190
191
191
}
@@ -233,8 +233,8 @@ object ConsoleProfileReporter extends ProfileReporter {
233
233
234
234
class StreamProfileReporter (out: PrintWriter ) extends ProfileReporter {
235
235
override def header (profiler : RealProfiler ): Unit = {
236
- out.println(s " info, ${profiler.id}, ${profiler.outDir}" )
237
- out.println(s " header(main/background),startNs,endNs,runId,phaseId,phaseName,purpose,threadId,threadName,runNs,idleNs,cpuTimeNs,userTimeNs,allocatedByte,heapSize " )
236
+ out.println(s " info, ${profiler.id}, version, 2, output, ${profiler.outDir}" )
237
+ out.println(s " header(main/background),startNs,endNs,runId,phaseId,phaseName,purpose,task-count, threadId,threadName,runNs,idleNs,cpuTimeNs,userTimeNs,allocatedByte,heapSize " )
238
238
out.println(s " header(GC),startNs,endNs,startMs,endMs,name,action,cause,threads " )
239
239
}
240
240
@@ -245,7 +245,7 @@ class StreamProfileReporter(out:PrintWriter) extends ProfileReporter {
245
245
reportCommon(EventType .MAIN , profiler, threadRange)
246
246
}
247
247
private def reportCommon (tpe: EventType .value, profiler : RealProfiler , threadRange : ProfileRange ): Unit = {
248
- out.println(s " $tpe, ${threadRange.start.snapTimeNanos}, ${threadRange.end.snapTimeNanos}, ${profiler.id}, ${threadRange.phase.id}, ${threadRange.phase.phaseName.replace(',' , ' ' )}, ${threadRange.purpose}, ${threadRange.thread.getId}, ${threadRange.thread.getName}, ${threadRange.runNs}, ${threadRange.idleNs}, ${threadRange.cpuNs}, ${threadRange.userNs}, ${threadRange.allocatedBytes}, ${if (tpe == EventType . MAIN ) threadRange.end.heapBytes else " " } " )
248
+ out.println(s " $tpe, ${threadRange.start.snapTimeNanos}, ${threadRange.end.snapTimeNanos}, ${profiler.id}, ${threadRange.phase.id}, ${threadRange.phase.phaseName.replace(',' , ' ' )}, ${threadRange.purpose}, ${threadRange.taskCount} , ${threadRange. thread.getId}, ${threadRange.thread.getName}, ${threadRange.runNs}, ${threadRange.idleNs}, ${threadRange.cpuNs}, ${threadRange.userNs}, ${threadRange.allocatedBytes}, ${threadRange.end.heapBytes} " )
249
249
}
250
250
251
251
override def reportGc (data : GcEventData ): Unit = {
0 commit comments