Add thermal status to benchmark results (#3051)
This commit is contained in:
@@ -2,10 +2,12 @@ package org.maplibre.android.testapp.activity.benchmark
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.os.Handler
|
||||
import android.os.PowerManager
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -188,7 +190,23 @@ class BenchmarkActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getThermalStatus(): Int {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
return powerManager.currentThermalStatus
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private fun setupMapView() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
powerManager.addThermalStatusListener {
|
||||
status -> println("Thermal status changed $status")
|
||||
}
|
||||
}
|
||||
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView.getMapAsync { maplibreMap: MapLibreMap ->
|
||||
val benchmarkResult = BenchmarkResult(arrayListOf())
|
||||
@@ -254,7 +272,7 @@ class BenchmarkActivity : AppCompatActivity() {
|
||||
|
||||
mapView.removeOnDidFinishRenderingFrameListener(listener)
|
||||
|
||||
return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore)
|
||||
return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore, getThermalStatus())
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
||||
@@ -31,7 +31,8 @@ data class BenchmarkRun(
|
||||
data class BenchmarkRunResult(
|
||||
val fps: Double,
|
||||
val encodingTimeStore: FrameTimeStore,
|
||||
val renderingTimeStore: FrameTimeStore
|
||||
val renderingTimeStore: FrameTimeStore,
|
||||
val thermalState: Int
|
||||
)
|
||||
|
||||
data class BenchmarkResult (
|
||||
@@ -46,6 +47,7 @@ fun jsonPayload(benchmarkResult: BenchmarkResult): JsonObject {
|
||||
addJsonObject {
|
||||
put("styleName", JsonPrimitive(run.first.styleName))
|
||||
put("syncRendering", JsonPrimitive(run.first.syncRendering))
|
||||
put("thermalState", JsonPrimitive(run.second.thermalState))
|
||||
put("fps", JsonPrimitive(run.second.fps))
|
||||
put("avgEncodingTime", JsonPrimitive(run.second.encodingTimeStore.average()))
|
||||
put("avgRenderingTime", JsonPrimitive(run.second.renderingTimeStore.average()))
|
||||
|
||||
Reference in New Issue
Block a user