Skip to content

Commit 7451ad2

Browse files
committed
kram-profile - improve report with count, thread names
Add back fullscreen menu too. Can't add menus after that Button.
1 parent 75e0845 commit 7451ad2

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

Diff for: kram-profile/kram-profile/kram_profileApp.swift

+37-10
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,25 @@ func buildPerfettoJsonFromBuildTimings(buildTimings: [String:BuildTiming]) -> St
765765
// Also sort or assign a sort_index to the tracks. Sort biggest to smallest.
766766
// Make the threadName for the track be the short filename.
767767

768+
// add the thread names, only using 3 threads
769+
if true {
770+
var event = CatapultEvent()
771+
event.name = "thread_name"
772+
let names = ["ParseTime", "ParseCount", "OptimizeTime"]
773+
for i in 0..<3 {
774+
event.args = [:]
775+
event.args!["name"] = AnyCodable(names[i])
776+
event.tid = i
777+
event.ph = "M"
778+
779+
// may not need these, but needed for sort below
780+
event.ts = 0
781+
event.dur = 0
782+
783+
events.append(event)
784+
}
785+
}
786+
768787
for buildTiming in buildTimings {
769788
let t = buildTiming.value
770789

@@ -777,8 +796,16 @@ func buildPerfettoJsonFromBuildTimings(buildTimings: [String:BuildTiming]) -> St
777796
event.ts = 0 // do we need this, just more data to encode
778797
event.dur = t.duration
779798
event.ph = "X"
780-
event.tid = t.type == "Source" ? 0 : 1
799+
let isHeader = t.type == "Source"
800+
event.tid = isHeader ? 0 : 2
781801
events.append(event)
802+
803+
// add count in seconds, so can view sorted by count below the duration above
804+
if isHeader {
805+
event.tid = 1
806+
event.dur = t.count * 10000 // in 0.1 secs, but high counts dominate the range then
807+
events.append(event)
808+
}
782809
}
783810

784811
// TODO: sort this by the duration
@@ -1709,15 +1736,6 @@ A tool to help profile mem, perf, and builds.
17091736
// https://forums.developer.apple.com/forums/thread/740591
17101737

17111738
CommandGroup(after: .toolbar) {
1712-
// must call through NSWindow
1713-
Button("See Below") {
1714-
// Window isn't set in AppDelegate, so menu item is skipped.
1715-
// But add fn+F menu item into app. So many stupid hacks.
1716-
// Can also go NSApp.windows.first, but not good w/multiple windows.
1717-
1718-
appDelegate.window?.toggleFullScreen(nil)
1719-
}
1720-
17211739
// TODO: only enable if build files are present
17221740
// eventually don't run this on all, maybe find those related to selection
17231741
Button("Build Report") {
@@ -1728,6 +1746,15 @@ A tool to help profile mem, perf, and builds.
17281746
}
17291747
}
17301748
.disabled(selection == nil)
1749+
1750+
// must call through NSWindow
1751+
Button("See Below") {
1752+
// Window isn't set in AppDelegate, so menu item is skipped.
1753+
// But add fn+F menu item into app. So many stupid hacks.
1754+
// Can also go NSApp.windows.first, but not good w/multiple windows.
1755+
1756+
appDelegate.window?.toggleFullScreen(nil)
1757+
}
17311758
}
17321759

17331760
CommandGroup(replacing: .appInfo) {

0 commit comments

Comments
 (0)