Skip to content

Commit

Permalink
kram-profile - fix info
Browse files Browse the repository at this point in the history
  • Loading branch information
alecazam committed Mar 5, 2024
1 parent 4968c3f commit f2776d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
50 changes: 39 additions & 11 deletions kram-profile/kram-profile/kram_profileApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ func loadFileJS(_ path: String) -> String? {
var threadName: String = ""
var startTime: Int = Int.max
var endTime: Int = Int.min
var endTimeFree: Int = Int.min
var count: Int = 0

// id doesn't implement Hashable
Expand All @@ -632,15 +633,45 @@ func loadFileJS(_ path: String) -> String? {
return lhs.id < rhs.id
}

func combine(_ s: Int, _ d: Int) {
startTime = min(startTime, s)
endTime = max(endTime, s+d)
func combine(_ s: Int, _ d: Int, _ name: String?) {
let isFreeBlock = name != nil && name! == "Free"
let e = s+d

if isFreeBlock {
endTimeFree = max(endTimeFree, e)

// If all free block, this doesn't work
// so update start/endTime assuming first block isn't Free
if startTime > endTime {
startTime = min(startTime, s)
endTime = max(endTime, e)
}
}
else {
startTime = min(startTime, s)
endTime = max(endTime, e)
}

count += 1
}

var description: String {
let duration = Double(endTime - startTime) * 1e-6
return "\(id) '\(threadName)' \(float: duration, decimals:6)s \(count)x"

// TODO: could display freeDuration (heap size)
var freeDuration = duration
if endTimeFree != Int.min {
freeDuration = Double(endTimeFree - startTime) * 1e-6
}
let percentage = freeDuration > 0.0 ? ((duration / freeDuration) * 100.0) : 0.0

// only disply percentage if needed
if percentage > 99.9 {
return "\(id) '\(threadName)' \(float: duration, decimals:6)s \(count)x"
}
else {
return "\(id) '\(threadName)' \(float: duration, decimals:6)s \(float:percentage, decimals:0)% \(count)x"
}
}

}
Expand Down Expand Up @@ -670,14 +701,11 @@ func loadFileJS(_ path: String) -> String? {
threadInfos[tid]!.threadName = threadName
}
else if event.ts != nil && event.dur != nil {
// using Free blocks to mark the end of the heap, so
// don't include them in the totals
if event.name != "Free" {
let s = event.ts!
let d = event.dur!
let s = event.ts!
let d = event.dur!

threadInfos[tid]!.combine(s, d)
}
threadInfos[tid]!.combine(s, d, event.name)

}
}

Expand Down
9 changes: 3 additions & 6 deletions scripts/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# note: zsh works on osx, but not on Win git bash, so using bash

# here is a post about grouping output using echo
# these cannot be nested
# https://github.com/orgs/community/discussions/25314

#-----------------------------------------------
Expand Down Expand Up @@ -55,8 +56,6 @@ fi
# can't just use cmake .. on osx, cmake gets confused about metal files since language not recognized
# but Xcode knows how to build these. I don't want to setup special rule for metal files right now.
if [[ $buildType == macos ]]; then
echo "::group::kram-mac"

# not using CMake anymore on mac/iOS. Using custom workspace and projects.
#cmake .. -G Xcode
# build the release build
Expand Down Expand Up @@ -103,16 +102,14 @@ if [[ $buildType == macos ]]; then
xcodebuild install -sdk macosx -project kram-profile.xcodeproj -configuration Release -destination generic/platform=macOS DSTROOT=${binHolderPath} INSTALL_PATH=bin
echo "::endgroup::"
popd

echo "::endgroup::"


elif [[ $buildType == windows ]]; then
# this builds kram.exe and thumbnailer
echo "::group::kram-win"
mkdir -p build

pushd build


# DONE: update to VS2022 and use clang
cmake .. -G "Visual Studio 17 2022" -T ClangCL -A x64

Expand Down

0 comments on commit f2776d8

Please sign in to comment.