android - close file handles in performance monitor

This commit is contained in:
Emmanuel Hansen 2024-01-21 14:08:39 +00:00
parent 29332c44ab
commit 0f1b737b07
2 changed files with 1 additions and 26 deletions

View File

@ -121,8 +121,6 @@ class MainActivity : BaseActivity() {
}
}
}
val freq = performanceMonitor.getFrequencies()
}
override fun onSaveInstanceState(outState: Bundle) {

View File

@ -11,33 +11,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import java.io.RandomAccessFile
import kotlin.concurrent.thread
class PerformanceMonitor {
val numberOfCores = Runtime.getRuntime().availableProcessors()
private var isMonitoring: Boolean = false
fun startMonitoring() {
if(isMonitoring)
return
isMonitoring = true
thread {
monitor()
}
}
init {
}
fun monitor(){
while(isMonitoring) {
//lastCpuUsages = HardwarePropertiesManager.
//Thread.sleep(1000);
}
}
fun getFrequencies() : List<Double> {
val frequencies = mutableListOf<Double>()
@ -49,6 +25,7 @@ class PerformanceMonitor {
"r"
)
val f = reader.readLine()
reader.close()
freq = f.toDouble() / 1000.0
}
catch (e:Exception){