Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add encoded histogram export #84

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

heckj
Copy link
Contributor

@heckj heckj commented Mar 4, 2023

Description

A work-around solution to #82, adding a feature to export the underlying histograms using their codable conformance. The preferred longer term solution requires additional features/capabilities on package-histogram to support cross-platform encoding and decoding of the raw histogram data.

This encoded histogram does not include the units of measurement selected for the various benchmarks.

How Has This Been Tested?

  • swift test within a linux container (Swift:5.7)
  • Manually verified the output from swift package --allow-writing-to-package-directory benchmark --format encodedHistogram from the main branch within a Linux container, and on macOS desktop.

Minimal checklist:

  • I have performed a self-review of my own code
  • I have added DocC code-level documentation for any public interfaces exported by the package
  • I have added unit and/or integration tests that prove my fix is effective or that my feature works

@@ -25,6 +25,7 @@ enum OutputFormat: String, ExpressibleByArgument, CaseIterable {
case percentiles
case tsv
case jmh
case encodedHistogram
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this for completeness sake

@codecov
Copy link

codecov bot commented Mar 4, 2023

Codecov Report

Merging #84 (145c773) into main (fa1a955) will not change coverage.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   81.48%   81.48%           
=======================================
  Files          19       19           
  Lines        2209     2209           
=======================================
  Hits         1800     1800           
  Misses        409      409           
Impacted Files Coverage Δ
Sources/BenchmarkSupport/BenchmarkRunner.swift 89.33% <0.00%> (ø)
Impacted Files Coverage Δ
Sources/BenchmarkSupport/BenchmarkRunner.swift 89.33% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa1a955...145c773. Read the comment docs.

@@ -88,6 +88,56 @@ extension BenchmarkTool {
}
}

/// Writes raw data into a file.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without Foundation, which wasn't imported, there wasn't a super convenient way to transform an array of [UInt8] into String, so I made a variant of the write function that accepted [UInt8] and wrote the raw data into the file.

If there's a better/preferred way of tackling this, I'd be happy to do so.

@@ -27,13 +27,19 @@ enum Grouping: String, ExpressibleByArgument {
case benchmark
}

/// The benchmark data output format.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added DocC comments to this OutputFormat enum, which otherwise seemed to be replicated in 3 places. I'm not sure where would be most appropriate, or if DocC additions make any notable difference here.

@@ -126,10 +132,10 @@ struct BenchmarkTool: AsyncParsableCommand {
}

func shouldRunBenchmark(_ name: String) throws -> Bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes flowed into place when I ran swiftformat . using the configuration within the repo. I presumed that was desired when submitting code changes. If not, I can back these out.

@@ -47,10 +47,10 @@ public struct BenchmarkRunner: AsyncParsableCommand, BenchmarkRunnerReadWrite {
var debug = false

func shouldRunBenchmark(_ name: String) throws -> Bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes flowed into place when I ran swiftformat . using the configuration within the repo. I presumed that was desired when submitting code changes. If not, I can back these out.

@heckj
Copy link
Contributor Author

heckj commented Mar 5, 2023

FWIW: here's the progress to date using the exported data taking advantage of the histogram 'Codable':

Screenshot 2023-03-05 at 3 36 30 PM

@hassila hassila self-requested a review March 6, 2023 08:16
Copy link
Contributor

@hassila hassila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution! 🎉

@hassila hassila merged commit 50554b4 into ordo-one:main Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants