Remove the redundant TimerUtil class.

This commit is contained in:
EliteMasterEric
2025-06-11 17:35:01 -07:00
committed by Kade
parent 5eecef17a1
commit 01fd37e08b
6 changed files with 2 additions and 95 deletions
-4
View File
@@ -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)}');
}
/**
@@ -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<Int> = [];
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;
}
@@ -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<Bytes> = state.audioInstTrackData.get(instId);
var perfStart:Float = TimerUtil.start();
var instTrack:Null<FunkinSound> = 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<Bytes> = state.audioVocalTrackData.get(trackId);
var perfStart:Float = TimerUtil.start();
var vocalTrack:Null<FunkinSound> = 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<WaveformData> = 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<WaveformData> = vocalTrack.waveformData;
trace('Interpreted waveform data in ${TimerUtil.seconds(perfStart)}.');
if (waveformData != null)
{
@@ -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.
-49
View File
@@ -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';
}
}
+2 -3
View File
@@ -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();
}
}