Skip to content

Commit

Permalink
fix the controlling avg and peak value of power
Browse files Browse the repository at this point in the history
  • Loading branch information
op06072 committed Jul 28, 2023
1 parent d29673a commit 55a503a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2363,5 +2363,37 @@
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "0919BE8D-2CF4-45CA-B173-DF6B976C1DAA"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "socpowerbuddy_swift/sampler.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "455"
endingLineNumber = "455"
landmarkName = "summary(sd:vd:rd:rvd:opt:)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8F3BCB03-688C-4D03-8D9C-59292D1BC5C9"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "socpowerbuddy_swift/neoasitop.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "204"
endingLineNumber = "204"
landmarkName = "launch()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
14 changes: 14 additions & 0 deletions socpowerbuddy_swift/head.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,17 @@ struct mem_info {
var used: [Double] = [0, 0]
var free: [Double] = [0, 0]
}

struct avg_pwr {
var sys: [Double] = []
var cpu: [Float] = []
var gpu: [Float] = []
var ram: [Float] = []
}

struct peak_pwr {
var sys: Double = 0
var cpu: Float = 0
var gpu: Float = 0
var ram: Float = 0
}
26 changes: 25 additions & 1 deletion socpowerbuddy_swift/neoasitop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var sd = static_data()
var cmd = cmd_data()
let sens = SensorsReader()

let cur_ver = "v2.8"
let cur_ver = "v2.9"
var newVersion = false

struct Neoasitop: ParsableCommand {
Expand Down Expand Up @@ -183,6 +183,9 @@ struct Neoasitop: ParsableCommand {
var scr = scrin!.tbx
var bottomPnt: OpaquePointer? = nil
xy = scrin!.xy

var pwr_max: peak_pwr = peak_pwr()
var pwr_avg: avg_pwr = avg_pwr()

while true {
autoreleasepool {
Expand All @@ -201,11 +204,32 @@ struct Neoasitop: ParsableCommand {
monInfo.cpu_pwr.val = cpu_pwr
monInfo.gpu_pwr.val = gpu_pwr

monInfo.sys_pwr_max = pwr_max.sys
monInfo.cpu_pwr_max = pwr_max.cpu
monInfo.gpu_pwr_max = pwr_max.gpu
monInfo.ram_pwr_max = pwr_max.ram

monInfo.sys_pwr_avg = pwr_avg.sys
monInfo.cpu_pwr_avg = pwr_avg.cpu
monInfo.gpu_pwr_avg = pwr_avg.gpu
monInfo.ram_pwr_avg = pwr_avg.ram

sample(iorep: iorep, sd: sd, vd: &vd!, cmd: cmd) // 데이터 샘플링 (애플 비공개 함수 이용)
//print("sampling finish")
format(sd: &sd, vd: &vd!) // 포매팅
//print("formatting finish")
summary(sd: sd, vd: vd!, rd: &rd!, rvd: &monInfo, opt: avg)

pwr_max.sys = monInfo.sys_pwr_max
pwr_max.cpu = monInfo.cpu_pwr_max
pwr_max.gpu = monInfo.gpu_pwr_max
pwr_max.ram = monInfo.ram_pwr_max

pwr_avg.sys = monInfo.sys_pwr_avg
pwr_avg.cpu = monInfo.cpu_pwr_avg
pwr_avg.gpu = monInfo.gpu_pwr_avg
pwr_avg.ram = monInfo.ram_pwr_avg

rd = nil
vd = nil
}
Expand Down
4 changes: 2 additions & 2 deletions socpowerbuddy_swift/sampler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ func summary(sd: static_data, vd: variating_data, rd: inout render_data, rvd: in
}
form = "CPU: %.2fW"
if stat_disp {
form += " (avd: %.\(pwr_unit)fW peak: %.\(pwr_unit)fW)"
form += " (avg: %.\(pwr_unit)fW peak: %.\(pwr_unit)fW)"
}
rvd.cpu_pwr.title = String(
format: form,
Expand Down Expand Up @@ -868,7 +868,7 @@ func summary(sd: static_data, vd: variating_data, rd: inout render_data, rvd: in
}
form = "GPU: %.2fW"
if stat_disp {
form += " (avd: %.\(pwr_unit)fW peak: %.\(pwr_unit)fW)"
form += " (avg: %.\(pwr_unit)fW peak: %.\(pwr_unit)fW)"
}
rvd.gpu_pwr.title = String(
format: form,
Expand Down

0 comments on commit 55a503a

Please sign in to comment.