mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-23 18:55:22 +01:00
#3215: Add time measurement per event listener method
This commit is contained in:
parent
42d8300bb7
commit
425ee4e142
@ -42,6 +42,8 @@ public class EventBus
|
||||
{
|
||||
for ( EventHandlerMethod method : handlers )
|
||||
{
|
||||
long start = System.nanoTime();
|
||||
|
||||
try
|
||||
{
|
||||
method.invoke( event );
|
||||
@ -55,6 +57,15 @@ public class EventBus
|
||||
{
|
||||
logger.log( Level.WARNING, MessageFormat.format( "Error dispatching event {0} to listener {1}", event, method.getListener() ), ex.getCause() );
|
||||
}
|
||||
|
||||
long elapsed = System.nanoTime() - start;
|
||||
if ( elapsed > 20000000 )
|
||||
{
|
||||
logger.log( Level.WARNING, "Plugin listener {0} took {1}ms to process event {2}!", new Object[]
|
||||
{
|
||||
method.getListener().getClass().getName(), elapsed / 1000000, event
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user