-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format metrics; add (min, med, max) for timing metrics (#1054)
- Loading branch information
1 parent
566d2b4
commit 296f1b9
Showing
12 changed files
with
89 additions
and
25 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...y-metrics/src/main/java/com/google/cloud/spark/bigquery/v2/customMetrics/MetricUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.google.cloud.spark.bigquery.v2.customMetrics; | ||
|
||
import static org.apache.spark.util.Utils.bytesToString; | ||
import static org.apache.spark.util.Utils.msDurationToString; | ||
|
||
import java.text.NumberFormat; | ||
import java.util.Arrays; | ||
import java.util.Locale; | ||
|
||
class MetricUtils { | ||
|
||
private static final String METRIC_FORMAT = "total (min, med, max)\n%s (%s, %s, %s)"; | ||
private static final NumberFormat NUMBER_FORMAT_US = NumberFormat.getIntegerInstance(Locale.US); | ||
|
||
static String formatTimeMetrics(long[] taskMetrics) { | ||
if (taskMetrics.length == 0) { | ||
return msDurationToString(0); | ||
} | ||
if (taskMetrics.length == 1) { | ||
return msDurationToString(taskMetrics[0]); | ||
} | ||
Arrays.sort(taskMetrics); | ||
String sum = msDurationToString(Arrays.stream(taskMetrics).sum()); | ||
String min = msDurationToString(taskMetrics[0]); | ||
String med = msDurationToString(taskMetrics[taskMetrics.length / 2]); | ||
String max = msDurationToString(taskMetrics[taskMetrics.length - 1]); | ||
return String.format(METRIC_FORMAT, sum, min, med, max); | ||
} | ||
|
||
static String formatSizeMetrics(long[] taskMetrics) { | ||
return bytesToString(Arrays.stream(taskMetrics).sum()); | ||
} | ||
|
||
static String formatSumMetrics(long[] taskMetrics) { | ||
return NUMBER_FORMAT_US.format(Arrays.stream(taskMetrics).sum()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters