mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
debug menu: show memory allocation rate
Yep, 80MB/s is pretty bad, ik
This commit is contained in:
parent
d870067a00
commit
b97da5fc47
@ -31,8 +31,8 @@ import de.bixilon.minosoft.gui.rendering.gui.hud.elements.bossbar.BossbarLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat.ChatElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar.HotbarElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.CrosshairHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.DebugHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.PerformanceHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug.DebugHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.scoreboard.ScoreboardSideElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.tab.TabListElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.title.TitleElement
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.CustomHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug.DebugHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
@ -24,6 +24,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug.DebugHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug
|
||||
|
||||
import de.bixilon.kutil.concurrent.schedule.RepeatedTask
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
||||
|
||||
object AllocationRate {
|
||||
const val RUNS_PER_SECOND = 3
|
||||
private val RUNTIME = Runtime.getRuntime()
|
||||
var allocationRate = 0L
|
||||
private set
|
||||
private var previous = 0L
|
||||
|
||||
init {
|
||||
TaskScheduler += RepeatedTask(1000 / RUNS_PER_SECOND) { tick() }
|
||||
}
|
||||
|
||||
private fun tick() {
|
||||
val previous = this.previous
|
||||
val allocated = RUNTIME.totalMemory() - RUNTIME.freeMemory()
|
||||
this.previous = allocated
|
||||
if (allocated < previous) {
|
||||
// gc was active
|
||||
return
|
||||
}
|
||||
this.allocationRate = (allocated - previous) * RUNS_PER_SECOND
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.other
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.other.debug
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec4.Vec4i
|
||||
@ -199,6 +199,8 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
||||
|
||||
layout += LineSpacerElement(guiRenderer)
|
||||
|
||||
layout += AutoTextElement(guiRenderer, 1) { "Allocation rate ${AllocationRate.allocationRate.formatBytes()}/s}" }
|
||||
|
||||
SystemInformation.RUNTIME.apply {
|
||||
layout += AutoTextElement(guiRenderer, 1) {
|
||||
val total = maxMemory()
|
Loading…
x
Reference in New Issue
Block a user