-
Notifications
You must be signed in to change notification settings - Fork 50
More benchmarker features #595
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
49c1d8c
Add option to show benchmark charts
rxwei 6ca5cfd
Add new comparison features
rctcwyvrn 74dd8e6
Add loading
rctcwyvrn 662870e
Accidently flipped the order
rctcwyvrn 1b761be
Disable compile time comparisons by default
rctcwyvrn e8d273a
Change chart to be a normalized performance graph
rctcwyvrn 2c12236
Add compile time measurement + cleanup
rctcwyvrn 1f6010c
Oops
rctcwyvrn a0af345
Add enum for comparison type
rctcwyvrn aff32e6
Merge branch 'main' into charts-and-compares
rctcwyvrn aa81037
Add canImport for CI
rctcwyvrn 8cdc76e
Add compiler options for tracing and metrics
rctcwyvrn 8101f55
Add metrics + update tracing
rctcwyvrn b9f68c8
Enable metrics and tracing on the benchmarker
rctcwyvrn 4b107a8
Fix tracing
rctcwyvrn 9062855
Cleanup benchmark protocols
rctcwyvrn b2a49f9
Add parse time measurement + cleanup benchmarker
rctcwyvrn 1de8128
Call parse directly
rctcwyvrn 205e4d3
Make comparison generic + Adjust stdev requirement to be a %
rctcwyvrn 82f71dd
Cleanup
rctcwyvrn 3d0789f
Cleanup
rctcwyvrn 9c8e567
Add conditional compilation for metric measuring
rctcwyvrn dbcb7fd
Fix spacing
rctcwyvrn c2b672f
Fix ns suffix mismatch
rctcwyvrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,81 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#if os(macOS) | ||
|
||
import Charts | ||
import SwiftUI | ||
|
||
struct BenchmarkChart: View { | ||
var comparisons: [BenchmarkResult.Comparison] | ||
|
||
var sortedComparisons: [BenchmarkResult.Comparison] { | ||
comparisons.sorted { a, b in | ||
a.latest.median.seconds/a.baseline.median.seconds < | ||
b.latest.median.seconds/b.baseline.median.seconds | ||
} | ||
} | ||
var body: some View { | ||
VStack(alignment: .leading) { | ||
Chart { | ||
ForEach(sortedComparisons) { comparison in | ||
let new = comparison.latest.median.seconds | ||
let old = comparison.baseline.median.seconds | ||
chartBody( | ||
name: comparison.name, | ||
new: new, | ||
old: old, | ||
sampleCount: comparison.latest.samples) | ||
} | ||
// Baseline | ||
RuleMark(y: .value("Time", 1.0)) | ||
.foregroundStyle(.red) | ||
.lineStyle(.init(lineWidth: 1, dash: [2])) | ||
|
||
}.frame(idealHeight: 400) | ||
} | ||
} | ||
|
||
@ChartContentBuilder | ||
func chartBody( | ||
name: String, | ||
new: TimeInterval, | ||
old: TimeInterval, | ||
sampleCount: Int | ||
) -> some ChartContent { | ||
// Normalized runtime | ||
BarMark( | ||
x: .value("Name", name), | ||
y: .value("Normalized runtime", new / old)) | ||
.foregroundStyle(LinearGradient( | ||
colors: [.accentColor, new - old <= 0 ? .green : .yellow], | ||
startPoint: .bottom, | ||
endPoint: .top)) | ||
} | ||
} | ||
|
||
struct BenchmarkResultApp: App { | ||
static var comparisons: [BenchmarkResult.Comparison]? | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
if let comparisons = Self.comparisons { | ||
ScrollView { | ||
BenchmarkChart(comparisons: comparisons) | ||
} | ||
} else { | ||
Text("No data") | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could inline this into the
ForEach { ... }
. I pulled this out tochartBody
because of "expression too complex". That doesn't happen with just one bar mark.