mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
reduce overhead of profiler when not profiling
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.profiler;
|
||||
|
||||
public class ProfileFrame implements AutoCloseable {
|
||||
private final Runnable action;
|
||||
|
||||
public ProfileFrame(Runnable action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
@@ -36,21 +36,6 @@ public interface Profiler {
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Return a {@link AutoCloseable} implementation that
|
||||
* may be used in a try-with-resources statement for
|
||||
* more intuitive profiling, with auto-push/pop.
|
||||
*
|
||||
* @param frame ID of frame.
|
||||
*
|
||||
* @return {@link AutoCloseable} implementation for use
|
||||
* in try-with-resources.
|
||||
*/
|
||||
default ProfileFrame profile(String frame) {
|
||||
push(frame);
|
||||
return new ProfileFrame(() -> pop(frame));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the profiler data.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user