Skip to content

Commit

Permalink
add support for untrace
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Baskakov committed Nov 5, 2021
1 parent 66ce529 commit 934e034
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/google/idea/perf/tracer/TracerCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sealed class TraceTarget {
val methodName: String?,
val parameterIndexes: List<Int>? = emptyList(),
// a redundant option to support user config tab
val traceOption: TraceOption = COUNT_AND_WALL_TIME
var traceOption: TraceOption = COUNT_AND_WALL_TIME
): TraceTarget()

val errors: List<String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ class TracerController(
}
is TraceTarget.Method -> {
runWithProgress { progress ->
TracerUserConfig.addUserTraceRequest(command.target)
if (command.enable) {
TracerUserConfig.addUserTraceRequest(command.target)
} else {
command.target.traceOption = TraceOption.UNTRACE
TracerUserConfig.addUserUntraceRequest(command.target)
}
val clazz = command.target.className
val method = command.target.methodName ?: "*"
val methodPattern = MethodFqName(clazz, method, "*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ object TracerUserConfig {

fun addUserUntraceRequest(entry: TraceTarget.Method) {
val sortKey = concatClassAndMethod(entry)
userTraceRequests.remove(sortKey)
val value = userTraceRequests[sortKey]
if (value != null && value.traceOption != TraceOption.UNTRACE) {
userTraceRequests.remove(sortKey)
} else {
userTraceRequests[sortKey] = entry
}
}

private fun concatClassAndMethod(entry: TraceTarget.Method): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class TracerUIConfig : JBTextArea() {
companion object {
private fun methodToString(method: TraceTarget.Method): String {
val option = if (method.traceOption == TraceOption.COUNT_AND_WALL_TIME) "+" else "-"
return "$option ${method.className}#${method.methodName}"
if (method.methodName == "*") {
return "$option ${method.className}"
} else {
return "$option ${method.className}::${method.methodName}"
}
}
}

Expand Down

0 comments on commit 934e034

Please sign in to comment.