Skip to content

Commit

Permalink
kram-profile - improve report with count, thread names
Browse files Browse the repository at this point in the history
Add back fullscreen menu too.  Can't add menus after that Button.
  • Loading branch information
alecazam committed Mar 16, 2024
1 parent 75e0845 commit 7451ad2
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions kram-profile/kram-profile/kram_profileApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,25 @@ func buildPerfettoJsonFromBuildTimings(buildTimings: [String:BuildTiming]) -> St
// Also sort or assign a sort_index to the tracks. Sort biggest to smallest.
// Make the threadName for the track be the short filename.

// add the thread names, only using 3 threads
if true {
var event = CatapultEvent()
event.name = "thread_name"
let names = ["ParseTime", "ParseCount", "OptimizeTime"]
for i in 0..<3 {
event.args = [:]
event.args!["name"] = AnyCodable(names[i])
event.tid = i
event.ph = "M"

// may not need these, but needed for sort below
event.ts = 0
event.dur = 0

events.append(event)
}
}

for buildTiming in buildTimings {
let t = buildTiming.value

Expand All @@ -777,8 +796,16 @@ func buildPerfettoJsonFromBuildTimings(buildTimings: [String:BuildTiming]) -> St
event.ts = 0 // do we need this, just more data to encode
event.dur = t.duration
event.ph = "X"
event.tid = t.type == "Source" ? 0 : 1
let isHeader = t.type == "Source"
event.tid = isHeader ? 0 : 2
events.append(event)

// add count in seconds, so can view sorted by count below the duration above
if isHeader {
event.tid = 1
event.dur = t.count * 10000 // in 0.1 secs, but high counts dominate the range then
events.append(event)
}
}

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

CommandGroup(after: .toolbar) {
// must call through NSWindow
Button("See Below") {
// Window isn't set in AppDelegate, so menu item is skipped.
// But add fn+F menu item into app. So many stupid hacks.
// Can also go NSApp.windows.first, but not good w/multiple windows.

appDelegate.window?.toggleFullScreen(nil)
}

// TODO: only enable if build files are present
// eventually don't run this on all, maybe find those related to selection
Button("Build Report") {
Expand All @@ -1728,6 +1746,15 @@ A tool to help profile mem, perf, and builds.
}
}
.disabled(selection == nil)

// must call through NSWindow
Button("See Below") {
// Window isn't set in AppDelegate, so menu item is skipped.
// But add fn+F menu item into app. So many stupid hacks.
// Can also go NSApp.windows.first, but not good w/multiple windows.

appDelegate.window?.toggleFullScreen(nil)
}
}

CommandGroup(replacing: .appInfo) {
Expand Down

0 comments on commit 7451ad2

Please sign in to comment.