From 5ced37d61eec96b924b4f1d9400fa9ec4198f66c Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Tue, 18 Apr 2023 10:43:15 +0200 Subject: [PATCH] profile: add profile_finish_ts Repeating change from #17636 for 6.2 release --- site/en/rules/performance.md | 1 + .../com/google/devtools/build/lib/profiler/Profiler.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/site/en/rules/performance.md b/site/en/rules/performance.md index 0f80fdb6673f2f..a59fc0bfc27595 100644 --- a/site/en/rules/performance.md +++ b/site/en/rules/performance.md @@ -278,6 +278,7 @@ Example: "otherData": { "build_id": "101bff9a-7243-4c1a-8503-9dc6ae4c3b05", "date": "Tue Jun 16 08:30:21 CEST 2020", + "profile_finish_ts": "1677666095162000", "output_base": "/usr/local/google/_bazel_johndoe/573d4be77eaa72b91a3dfaa497bf8cd0" }, "traceEvents": [ 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 a99ed7e4bc93f2..913a46d08e215b 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 @@ -39,6 +39,7 @@ import java.lang.management.ManagementFactory; import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -1086,13 +1087,15 @@ public void run() { // The buffer size of 262144 is chosen at random. new OutputStreamWriter( new BufferedOutputStream(outStream, 262144), StandardCharsets.UTF_8))) { + var finishDate = Instant.now(); writer.beginObject(); writer.name("otherData"); writer.beginObject(); writer.name("bazel_version").value(BlazeVersionInfo.instance().getReleaseName()); writer.name("build_id").value(buildID.toString()); writer.name("output_base").value(outputBase); - writer.name("date").value(new Date().toString()); + writer.name("date").value(finishDate.toString()); + writer.name("profile_finish_ts").value(finishDate.getEpochSecond() * 1000); writer.endObject(); writer.name("traceEvents"); writer.beginArray();