diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index e066980b2..7a1a23c41 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -33,7 +33,6 @@ import funkin.ui.transition.LoadingState; import funkin.util.CLIUtil; import funkin.util.CLIUtil.CLIParams; import funkin.util.macro.MacroUtil; -import funkin.util.TimerUtil; import funkin.util.TrackerUtil; import funkin.util.WindowUtil; import openfl.display.BitmapData; @@ -231,7 +230,6 @@ class InitState extends FlxState // NOTE: Registries must be imported and not referenced with fully qualified names, // to ensure build macros work properly. trace('Parsing game data...'); - var perfStart:Float = TimerUtil.start(); SongEventRegistry.loadEventCache(); // SongEventRegistry is structured differently so it's not a BaseRegistry. SongRegistry.instance.loadEntries(); LevelRegistry.instance.loadEntries(); @@ -258,8 +256,6 @@ class InitState extends FlxState funkin.input.Cursor.hide(); funkin.FunkinMemory.initialCache(); - - trace('Parsing game data took: ${TimerUtil.ms(perfStart)}'); } /** diff --git a/source/funkin/audio/waveform/WaveformDataParser.hx b/source/funkin/audio/waveform/WaveformDataParser.hx index ca421581b..f9d6f63cc 100644 --- a/source/funkin/audio/waveform/WaveformDataParser.hx +++ b/source/funkin/audio/waveform/WaveformDataParser.hx @@ -1,7 +1,5 @@ package funkin.audio.waveform; -import funkin.util.TimerUtil; - class WaveformDataParser { static final INT16_MAX:Int = 32767; @@ -73,8 +71,6 @@ class WaveformDataParser var outputData:Array = []; - var perfStart:Float = TimerUtil.start(); - for (pointIndex in 0...outputPointCount) { // minChannel1, maxChannel1, minChannel2, maxChannel2, ... @@ -110,8 +106,6 @@ class WaveformDataParser var outputDataLength:Int = Std.int(outputData.length / channels / 2); var result = new WaveformData(null, channels, sampleRate, samplesPerPoint, bitsPerSample, outputPointCount, outputData); - trace('[WAVEFORM] Interpreted audio buffer in ${TimerUtil.seconds(perfStart)}.'); - return result; } diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx index 329873d68..61a831b45 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx @@ -6,7 +6,6 @@ import funkin.audio.FunkinSound; import funkin.play.character.BaseCharacter.CharacterType; import funkin.util.FileUtil; import funkin.util.assets.SoundUtil; -import funkin.util.TimerUtil; import funkin.audio.waveform.WaveformData; import funkin.audio.waveform.WaveformDataParser; import funkin.audio.waveform.WaveformSprite; @@ -127,42 +126,21 @@ class ChartEditorAudioHandler public static function switchToInstrumental(state:ChartEditorState, instId:String = '', playerId:String, opponentId:String):Bool { - var perfA:Float = TimerUtil.start(); - var result:Bool = playInstrumental(state, instId); if (!result) return false; - var perfB:Float = TimerUtil.start(); - stopExistingVocals(state); - var perfC:Float = TimerUtil.start(); - result = playVocals(state, BF, playerId, instId); - var perfD:Float = TimerUtil.start(); - // if (!result) return false; result = playVocals(state, DAD, opponentId, instId); // if (!result) return false; - var perfE:Float = TimerUtil.start(); - state.hardRefreshOffsetsToolbox(); - var perfF:Float = TimerUtil.start(); - state.hardRefreshFreeplayToolbox(); - var perfG:Float = TimerUtil.start(); - - trace('Switched to instrumental in ${TimerUtil.seconds(perfA, perfB)}.'); - trace('Stopped existing vocals in ${TimerUtil.seconds(perfB, perfC)}.'); - trace('Played BF vocals in ${TimerUtil.seconds(perfC, perfD)}.'); - trace('Played DAD vocals in ${TimerUtil.seconds(perfD, perfE)}.'); - trace('Hard refreshed offsets toolbox in ${TimerUtil.seconds(perfE, perfF)}.'); - trace('Hard refreshed freeplay toolbox in ${TimerUtil.seconds(perfF, perfG)}.'); - return true; } @@ -173,9 +151,7 @@ class ChartEditorAudioHandler { if (instId == '') instId = 'default'; var instTrackData:Null = state.audioInstTrackData.get(instId); - var perfStart:Float = TimerUtil.start(); var instTrack:Null = SoundUtil.buildSoundFromBytes(instTrackData); - trace('Built instrumental track in ${TimerUtil.seconds(perfStart)} seconds.'); if (instTrack == null) return false; stopExistingInstrumental(state); @@ -203,9 +179,7 @@ class ChartEditorAudioHandler { var trackId:String = '${charId}${instId == '' ? '' : '-${instId}'}'; var vocalTrackData:Null = state.audioVocalTrackData.get(trackId); - var perfStart:Float = TimerUtil.start(); var vocalTrack:Null = SoundUtil.buildSoundFromBytes(vocalTrackData); - trace('Built vocal track in ${TimerUtil.seconds(perfStart)}.'); if (state.audioVocalTrackGroup == null) state.audioVocalTrackGroup = new VoicesGroup(); @@ -216,9 +190,7 @@ class ChartEditorAudioHandler case BF: state.audioVocalTrackGroup.addPlayerVoice(vocalTrack); - var perfStart:Float = TimerUtil.start(); var waveformData:Null = vocalTrack.waveformData; - trace('Interpreted waveform data in ${TimerUtil.seconds(perfStart)}.'); if (waveformData != null) { @@ -242,9 +214,7 @@ class ChartEditorAudioHandler case DAD: state.audioVocalTrackGroup.addOpponentVoice(vocalTrack); - var perfStart:Float = TimerUtil.start(); var waveformData:Null = vocalTrack.waveformData; - trace('Interpreted waveform data in ${TimerUtil.seconds(perfStart)}.'); if (waveformData != null) { diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx index 5dced1a89..b17025ab2 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx @@ -6,7 +6,6 @@ import funkin.audio.SoundGroup; import funkin.ui.debug.charting.commands.SetFreeplayPreviewCommand; import funkin.ui.haxeui.components.WaveformPlayer; import funkin.ui.freeplay.FreeplayState; -import funkin.util.TimerUtil; import haxe.ui.backend.flixel.components.SpriteWrapper; import haxe.ui.components.Button; import haxe.ui.components.Label; @@ -283,12 +282,10 @@ class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox // Build player waveform. // waveformMusic.waveform.forceUpdate = true; - var perfStart:Float = TimerUtil.start(); var waveformData1 = playerVoice?.waveformData; var waveformData2 = opponentVoice?.waveformData ?? playerVoice?.waveformData; // this null check is for songs that only have 1 vocals file! var waveformData3 = chartEditorState.audioInstTrack.waveformData; var waveformData = waveformData3.merge(waveformData1).merge(waveformData2); - trace('Waveform data merging took: ${TimerUtil.seconds(perfStart)}'); waveformMusic.waveform.waveformData = waveformData; // Set the width and duration to render the full waveform, with the clipRect applied we only render a segment of it. diff --git a/source/funkin/util/TimerUtil.hx b/source/funkin/util/TimerUtil.hx deleted file mode 100644 index eb2690e16..000000000 --- a/source/funkin/util/TimerUtil.hx +++ /dev/null @@ -1,49 +0,0 @@ -package funkin.util; - -import funkin.util.tools.FloatTools; -import haxe.Timer; - -class TimerUtil -{ - /** - * Store the current time. - */ - public static function start():Float - { - return Timer.stamp(); - } - - /** - * Return the elapsed time. - */ - static function took(start:Float, ?end:Float):Float - { - var endOrNow:Float = end != null ? end : Timer.stamp(); - return endOrNow - start; - } - - /** - * Return the elapsed time in seconds as a string. - * @param start The start time. - * @param end The end time. - * @param precision The number of decimal places to round to. - * @return The elapsed time in seconds as a string. - */ - public static function seconds(start:Float, ?end:Float, ?precision = 2):String - { - var seconds:Float = FloatTools.round(took(start, end), precision); - return '${seconds} seconds'; - } - - /** - * Return the elapsed time in milliseconds as a string. - * @param start The start time. - * @param end The end time. - * @return The elapsed time in milliseconds as a string. - */ - public static function ms(start:Float, ?end:Float):String - { - var seconds:Float = took(start, end); - return '${seconds * 1000} ms'; - } -} diff --git a/source/funkin/util/plugins/MemoryGCPlugin.hx b/source/funkin/util/plugins/MemoryGCPlugin.hx index 4b89fa637..d6fb632da 100644 --- a/source/funkin/util/plugins/MemoryGCPlugin.hx +++ b/source/funkin/util/plugins/MemoryGCPlugin.hx @@ -1,7 +1,6 @@ package funkin.util.plugins; import flixel.FlxBasic; -import funkin.util.TimerUtil; /** * A plugin which adds functionality to press `Ins` to immediately perform memory garbage collection. @@ -24,9 +23,9 @@ class MemoryGCPlugin extends FlxBasic if (FlxG.keys.justPressed.INSERT) { - var perfStart:Float = TimerUtil.start(); + var perf = new funkin.util.logging.Perf(); funkin.util.MemoryUtil.collect(true); - trace('Memory GC took: ${TimerUtil.seconds(perfStart)}'); + perf.print(); } }