From 33a55dc7cdae68979d304b335eef103e0bc4a65f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 22 Nov 2025 09:30:00 -0600 Subject: [PATCH] Delete EventTimer.java --- .../core/util/objects/EventTimer.java | 115 ------------------ 1 file changed, 115 deletions(-) delete mode 100644 core/src/main/java/com/seibel/distanthorizons/core/util/objects/EventTimer.java diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/EventTimer.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/EventTimer.java deleted file mode 100644 index 847325777..000000000 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/EventTimer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of the Distant Horizons mod - * licensed under the GNU LGPL v3 License. - * - * Copyright (C) 2020 James Seibel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, version 3. - * - * 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.seibel.distanthorizons.core.util.objects; - -import java.time.Duration; -import java.util.ArrayList; - -public class EventTimer -{ - public static class Event - { - public long timeNs = -1; - public String name; - Event(String name) - { - this.name = name; - } - - } - - long lastEventNs = -1; - - public ArrayList events = new ArrayList<>(); - - public EventTimer(String firstEventName) - { - this.lastEventNs = System.nanoTime(); - this.events.add(new Event(firstEventName)); - } - - public void nextEvent(String name) - { - long timeNs = System.nanoTime(); - if (this.lastEventNs != -1 - && !this.events.isEmpty() - && this.events.get(this.events.size() - 1).timeNs == -1) - { - this.events.get(this.events.size() - 1).timeNs = timeNs - this.lastEventNs; - } - this.lastEventNs = timeNs; - this.events.add(new Event(name)); - } - - public void complete() - { - long timeNs = System.nanoTime(); - if (this.lastEventNs != -1 - && !this.events.isEmpty() - && this.events.get(this.events.size() - 1).timeNs == -1) - { - this.events.get(this.events.size() - 1).timeNs = timeNs - this.lastEventNs; - } - this.lastEventNs = -1; - } - - public long getEventTimeNs(String name) - { - for (Event e : this.events) - { - if (e.name.equals(name)) - { - return e.timeNs; - } - } - return -1; - } - - public long getTotalTimeNs() - { - long total = 0; - for (Event e : this.events) - { - if (e.timeNs != -1) - { - total += e.timeNs; - } - } - return total; - } - - public String toString() - { - StringBuilder sb = new StringBuilder(); - for (Event e : this.events) - { - if (e.timeNs != -1) - { - sb.append(e.name).append(": ").append(Duration.ofNanos(e.timeNs)).append('\n'); - } - else - { - sb.append(e.name).append(": ").append("N/A").append('\n'); - } - } - return sb.toString(); - } - -}