-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record HdrHistogram for standard REST perf tests
- Loading branch information
1 parent
fa06626
commit 473c8e9
Showing
2 changed files
with
78 additions
and
35 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
perf-tests/src/test/scala/sttp/tapir/perf/HistogramPrinter.scala
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,25 @@ | ||
package sttp.tapir.perf | ||
|
||
import org.HdrHistogram.Histogram | ||
|
||
import java.io.{FileOutputStream, PrintStream} | ||
import java.nio.file.Paths | ||
import scala.util.{Failure, Success, Using} | ||
|
||
object HistogramPrinter { | ||
def saveToFile(histogram: Histogram, histogramName: String): Unit = { | ||
val baseDir = System.getProperty("user.dir") | ||
val targetFilePath = Paths.get(baseDir).resolve(s"$histogramName-${System.currentTimeMillis()}") | ||
Using.Manager { use => | ||
val fos = use(new FileOutputStream(targetFilePath.toFile)) | ||
val ps = use(new PrintStream(fos)) | ||
histogram.outputPercentileDistribution(System.out, 1.0) | ||
histogram.outputPercentileDistribution(ps, 1.0) | ||
} match { | ||
case Success(_) => | ||
println(s"******* Histogram saved to $targetFilePath") | ||
case Failure(ex) => | ||
ex.printStackTrace | ||
} | ||
} | ||
} |
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