Skip to content

Commit

Permalink
chore(benchmarking): Fix throughput conversion issue and report metri…
Browse files Browse the repository at this point in the history
…cs in seconds (#2211)

* chore(benchmarking): Fix throughput conversion issue and report metrics in seconds

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sydney-munro and gcf-owl-bot[bot] authored Sep 25, 2023
1 parent 7401f21 commit 834732c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public static void cleanupObject(Storage storage, Blob created) {
created.getBlobId(), Storage.BlobSourceOption.generationMatch(created.getGeneration()));
}

public static double calculateThroughput(long size, Duration elapsedTime) {
return size >= StorageSharedBenchmarkingUtils.SSB_SIZE_THRESHOLD_BYTES
? size / 1024 / 1024 / (elapsedTime.toNanos())
: size / 1024 / (elapsedTime.toNanos());
public static double calculateThroughput(double size, Duration elapsedTime) {
double adjustedSize =
size >= StorageSharedBenchmarkingUtils.SSB_SIZE_THRESHOLD_BYTES
? (size / 1024D) / 1024D
: size / 1024D;
double throughput = adjustedSize / (elapsedTime.toMillis() / 1000D);
return throughput;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ final class W1R3 implements Callable<String> {
@Override
public String call() throws Exception {
// Create the file to be uploaded and fill it with data

try (TmpFile file = DataGenerator.base64Characters().tempFile(tempDirectory, objectSize)) {
BlobInfo blob = BlobInfo.newBuilder(bucketName, file.toString()).build();

// Get the start time
Clock clock = Clock.systemDefaultZone();
Instant startTime = clock.instant();
Expand All @@ -71,7 +71,7 @@ public String call() throws Exception {
generateCloudMonitoringResult(
"WRITE",
StorageSharedBenchmarkingUtils.calculateThroughput(
created.getSize().longValue(), elapsedTimeUpload),
created.getSize().doubleValue(), elapsedTimeUpload),
created)
.formatAsCustomMetric());
for (int i = 0; i <= StorageSharedBenchmarkingUtils.DEFAULT_NUMBER_OF_READS; i++) {
Expand All @@ -84,7 +84,7 @@ public String call() throws Exception {
generateCloudMonitoringResult(
"READ[" + i + "]",
StorageSharedBenchmarkingUtils.calculateThroughput(
created.getSize().longValue(), elapsedTimeDownload),
created.getSize().doubleValue(), elapsedTimeDownload),
created)
.formatAsCustomMetric());
}
Expand Down

0 comments on commit 834732c

Please sign in to comment.