Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 353590969
  • Loading branch information
Googler authored and copybara-github committed Jan 25, 2021
1 parent 667ae2a commit 0898a2a
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions src/main/java/com/google/devtools/build/lib/profiler/Profiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,12 @@ void logEvent(ProfilerTask type, String description) {
* have any subtasks, logSimpleTask() should be used instead.
*
* <p>Use like this:
* <pre>
* {@code
*
* <pre>{@code
* try (SilentCloseable c = Profiler.instance().profile(type, "description")) {
* // Your code here.
* }
* }
* </pre>
* }</pre>
*
* @param type predefined task type - see ProfilerTask for available types.
* @param description task description. May be stored until the end of the build.
Expand All @@ -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.
*
* <p>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.
*
* <p>This is a convenience method that uses {@link ProfilerTask#INFO}.
*
* <p>Use like this:
*
* <pre>{@code
* try (SilentCloseable c = Profiler.instance().profile("description")) {
* // Your code here.
* }
* }</pre>
*
* @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.
Expand All @@ -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.
*
* <p>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.
*
* <p>This is a convenience method that uses {@link ProfilerTask#INFO}.
*
* <p>Use like this:
* <pre>
* {@code
* try (SilentCloseable c = Profiler.instance().profile("description")) {
* // Your code here.
* }
* }
* </pre>
*
* @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));
Expand Down

0 comments on commit 0898a2a

Please sign in to comment.