Skip to content

Commit

Permalink
Add thermal status to benchmark results (#3051)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-cojocaru authored Nov 27, 2024
1 parent 06fb181 commit 69660be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -254,7 +272,7 @@ class BenchmarkActivity : AppCompatActivity() {

mapView.removeOnDidFinishRenderingFrameListener(listener)

return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore)
return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore, getThermalStatus())
}

override fun onStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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()))
Expand Down

0 comments on commit 69660be

Please sign in to comment.