mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: adjusted CPU stress test to prevent compiler to optimize it (#2391)
This commit is contained in:
@@ -1646,7 +1646,7 @@ public class CPUeStressTest {
|
||||
|
||||
let efficientCoreCount = ProcessInfo.processInfo.processorCount / 2
|
||||
self.workers.removeAll()
|
||||
|
||||
|
||||
for index in 0..<efficientCoreCount {
|
||||
let worker = DispatchWorkItem { [weak self] in
|
||||
self?.test(threadIndex: index)
|
||||
@@ -1664,8 +1664,9 @@ public class CPUeStressTest {
|
||||
|
||||
private func test(threadIndex: Int) {
|
||||
pthread_set_qos_class_self_np(QOS_CLASS_BACKGROUND, 0)
|
||||
var result: Double = 0.0
|
||||
while isRunning {
|
||||
_ = sqrt(987654.321)
|
||||
result += sqrt(987654.321)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1702,8 +1703,9 @@ public class CPUpStressTest {
|
||||
|
||||
private func test(threadIndex: Int) {
|
||||
pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0)
|
||||
var result: Double = 0.0
|
||||
while isRunning {
|
||||
_ = sqrt(987654.321)
|
||||
result += sqrt(987654.321)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user