diff --git a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java index 9149cac0baf18e..3f756788455fa4 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java @@ -633,13 +633,12 @@ void logEvent(ProfilerTask type, String description) { * have any subtasks, logSimpleTask() should be used instead. * *
Use like this: - *
- * {@code + * + ** * @param type predefined task type - see ProfilerTask for available types. * @param description task description. May be stored until the end of the build. @@ -660,6 +659,30 @@ public SilentCloseable profile(ProfilerTask type, String description) { } } + /** + * Records the beginning of a task as specified, and returns a {@link SilentCloseable} instance + * that ends the task. This lets the system do the work of ending the task, with the compiler + * giving a warning if the returned instance is not closed. + * + *{@code * try (SilentCloseable c = Profiler.instance().profile(type, "description")) { * // Your code here. * } - * } - *+ * }
Use of this method allows to support nested task monitoring. For tasks that are known to not + * have any subtasks, logSimpleTask() should be used instead. + * + *
This is a convenience method that uses {@link ProfilerTask#INFO}. + * + *
Use like this: + * + *
{@code + * try (SilentCloseable c = Profiler.instance().profile("description")) { + * // Your code here. + * } + * }+ * + * @param description task description. May be stored until the end of the build. + */ + public SilentCloseable profile(String description) { + return profile(ProfilerTask.INFO, description); + } + /** * Similar to {@link #profile}, but specific to action-related events. Takes an extra argument: * primaryOutput. @@ -684,31 +707,6 @@ public SilentCloseable profileAction( private static final SilentCloseable NOP = () -> {}; - /** - * Records the beginning of a task as specified, and returns a {@link SilentCloseable} instance - * that ends the task. This lets the system do the work of ending the task, with the compiler - * giving a warning if the returned instance is not closed. - * - *
Use of this method allows to support nested task monitoring. For tasks that are known to not - * have any subtasks, logSimpleTask() should be used instead. - * - *
This is a convenience method that uses {@link ProfilerTask#INFO}. - * - *
Use like this: - *
- * {@code - * try (SilentCloseable c = Profiler.instance().profile("description")) { - * // Your code here. - * } - * } - *- * - * @param description task description. May be stored until the end of the build. - */ - public SilentCloseable profile(String description) { - return profile(ProfilerTask.INFO, description); - } - private boolean countAction(ProfilerTask type, TaskData taskData) { return type == ProfilerTask.ACTION || (type == ProfilerTask.INFO && "discoverInputs".equals(taskData.description));