private static <T> T _timedSearch (@Nonnull final IThrowingSupplier <T, IOException> aRunnable, @Nonnull final Query aQuery) throws IOException { final StopWatch aSW = StopWatch.createdStarted (); try { return aRunnable.get (); } finally { final long nMillis = aSW.stopAndGetMillis (); s_aStatsQueryTimer.addTime (aQuery.toString (), nMillis); if (nMillis > CGlobal.MILLISECONDS_PER_SECOND) LOGGER.warn ("Lucene Query " + aQuery + " took too long: " + nMillis + "ms"); } }
@Nonnull final Callable <T> aCallable) final StopWatch aSW = StopWatch.createdStarted (); final EntityTransaction aTransaction = aEntityMgr.getTransaction (); final boolean bTransactionRequired = !bAllowNestedTransactions || !aTransaction.isActive (); aTransaction.commit (); s_aStatsCounterSuccess.increment (); s_aStatsTimerExecutionSuccess.addTime (aSW.stopAndGetMillis ()); return JPAExecutionResult.createSuccess (ret); s_aStatsTimerExecutionError.addTime (aSW.stopAndGetMillis ()); _invokeCustomExceptionCallback (ex); return JPAExecutionResult.createFailure (ex); if (aSW.getMillis () > getDefaultExecutionWarnTime ()) onExecutionTimeExceeded ("Callback: " + aSW.getMillis () + " ms; transaction: " + bTransactionRequired + "; Execution of callable in transaction took too long: " + aCallable.toString (), aSW.getMillis ());
@Override protected final void doPost (@Nonnull final HttpServletRequest aHttpRequest, @Nonnull final HttpServletResponse aHttpResponse) throws ServletException, IOException { final RequestScopeInitializer aRequestScopeInitializer = beforeRequest (aHttpRequest, aHttpResponse); final StopWatch aSW = new StopWatch (true); try { onPost (aHttpRequest, aHttpResponse, aRequestScopeInitializer.getRequestScope ()); } finally { s_aTimerHdlPost.addTime (aSW.stopAndGetMillis ()); aRequestScopeInitializer.destroyScope (); } }
final StopWatch aSW = StopWatch.createdStarted (); DataSource aMsgDataSource = null; try aSW.stop ();
public void beforeRequest (@Nonnull final IRequestWebScope aRequestScope) { m_aSW = StopWatch.createdStarted (); }
public void afterRequest (@Nonnull final IRequestWebScope aRequestScope) { // Timer per HTTP method m_aTimer.addTime (aRequestScope.getHttpMethod ().getName (), m_aSW.stopAndGetMillis ()); } }
final StopWatch aSW = StopWatch.createdStarted (); try LOGGER.debug ("Response retrieved: " + aResponse.getAsString ()); aResponse.setExecutionDuration (aSW.stopAndGetDuration ()); return aResponse;
@Nonnull @Nonempty public static String getTransferRate (final long nBytes, @Nonnull final StopWatch aSW) { final StringBuilder aSB = new StringBuilder (); aSB.append (nBytes).append (" bytes in ").append (aSW.getMillis () / 1000.0).append (" seconds at "); final long nMillis = aSW.getMillis (); if (nMillis != 0) { final double dSeconds = nMillis / 1000.0; final long nBytesPerSecond = Math.round (nBytes / dSeconds); aSB.append (_getTransferRate (nBytesPerSecond)); } else { aSB.append (_getTransferRate (nBytes)); } return aSB.toString (); }
final StopWatch aSW = StopWatch.createdStarted (); final long nBytes = AS2IOHelper.copy (aMessageIS, aMsgOS); aOutgoingDumper.finishedPayload (); aSW.stop (); if (LOGGER.isInfoEnabled ()) LOGGER.info ("transferred " + AS2IOHelper.getTransferRate (nBytes, aSW) + aMsg.getLoggingText ());
public final void contextDestroyed (@Nonnull final ServletContextEvent aSCE) { final ServletContext aSC = aSCE.getServletContext (); final StopWatch aSW = StopWatch.createdStarted (); if (LOGGER.isInfoEnabled ()) LOGGER.info ("Servlet context '" + aSC.getServletContextName () + "' is being destroyed"); // Callback before global scope end beforeContextDestroyed (aSC); // Shutdown global scope and destroy all singletons WebScopeManager.onGlobalEnd (); // Callback after global scope end afterContextDestroyed (aSC); // Handle statistics if (isHandleStatisticsOnEnd ()) handleStatisticsOnEnd (); // Clean commons stuff etc PhotonBasic.shutdown (); if (isOnlyOneInstanceAllowed ()) { // De-init s_aInited.set (false); } if (LOGGER.isInfoEnabled ()) LOGGER.info ("Servlet context '" + aSC.getServletContextName () + "' was destroyed in " + aSW.stopAndGetMillis () + " milli seconds"); }
final StopWatch aSW = StopWatch.createdStarted (); try s_aStatsTimerExecutionSuccess.addTime (aSW.stopAndGetMillis ()); return JPAExecutionResult.createSuccess (ret); s_aStatsTimerExecutionError.addTime (aSW.stopAndGetMillis ()); _invokeCustomExceptionCallback (ex); return JPAExecutionResult.<T> createFailure (ex); if (aSW.getMillis () > getDefaultExecutionWarnTime ()) onExecutionTimeExceeded ("Execution of select took too long: " + aCallable.toString (), aSW.getMillis ());
@Override protected final void doPut (@Nonnull final HttpServletRequest aHttpRequest, @Nonnull final HttpServletResponse aHttpResponse) throws ServletException, IOException { final RequestScopeInitializer aRequestScopeInitializer = beforeRequest (aHttpRequest, aHttpResponse); final StopWatch aSW = new StopWatch (true); try { onPut (aHttpRequest, aHttpResponse, aRequestScopeInitializer.getRequestScope ()); } finally { s_aTimerHdlPut.addTime (aSW.stopAndGetMillis ()); aRequestScopeInitializer.destroyScope (); } }
final StopWatch aSW = StopWatch.createdStarted (); final long nBytes = ((AS2HttpClient) aConn).send (aMsgIS, eCTE, aOutgoingDumper); aSW.stop (); LOGGER.info ("transferred " + AS2IOHelper.getTransferRate (nBytes, aSW) + aMsg.getLoggingText ()); final StopWatch aSW = StopWatch.createdStarted (); aSW.stop (); LOGGER.info ("transferred " + AS2IOHelper.getTransferRate (nBytes, aSW) + aMsg.getLoggingText ());
final StopWatch aSW = StopWatch.createdStarted (); final ThreadDescriptorList ret = new ThreadDescriptorList (); try final long nMillis = aSW.stopAndGetMillis (); if (nMillis > 1000) if (LOGGER.isWarnEnabled ())
@Override protected final void doHead (@Nonnull final HttpServletRequest aHttpRequest, @Nonnull final HttpServletResponse aHttpResponse) throws ServletException, IOException { final RequestScopeInitializer aRequestScopeInitializer = beforeRequest (aHttpRequest, aHttpResponse); final StopWatch aSW = new StopWatch (true); try { onHead (aHttpRequest, aHttpResponse, aRequestScopeInitializer.getRequestScope ()); } finally { s_aTimerHdlHead.addTime (aSW.stopAndGetMillis ()); aRequestScopeInitializer.destroyScope (); } }
final StopWatch aSW = StopWatch.createdStarted (); eWriteSuccess = _writeToFile (); m_aStatsCounterInitTimer.addTime (aSW.stopAndGetMillis ()); m_aStatsCounterInitSuccess.increment (); m_nInitCount++; try final StopWatch aSW = StopWatch.createdStarted (); m_aStatsCounterReadTimer.addTime (aSW.stopAndGetMillis ()); m_aStatsCounterReadSuccess.increment (); m_nReadCount++;
@Override protected final void doGet (@Nonnull final HttpServletRequest aHttpRequest, @Nonnull final HttpServletResponse aHttpResponse) throws ServletException, IOException { final RequestScopeInitializer aRequestScopeInitializer = beforeRequest (aHttpRequest, aHttpResponse); final StopWatch aSW = new StopWatch (true); try { onGet (aHttpRequest, aHttpResponse, aRequestScopeInitializer.getRequestScope ()); } finally { s_aTimerHdlGet.addTime (aSW.stopAndGetMillis ()); aRequestScopeInitializer.destroyScope (); } }
try final StopWatch aSW = StopWatch.createdStarted (); DocumentBuilder aDocumentBuilder; boolean bFromPool = false; s_aDomTimerHdl.addTime (aSW.stopAndGetMillis ()); else s_aDomSchemaTimerHdl.addTime (aSW.stopAndGetMillis ());
@Override protected final void doTrace (@Nonnull final HttpServletRequest aHttpRequest, @Nonnull final HttpServletResponse aHttpResponse) throws ServletException, IOException { final RequestScopeInitializer aRequestScopeInitializer = beforeRequest (aHttpRequest, aHttpResponse); final StopWatch aSW = new StopWatch (true); try { onTrace (aHttpRequest, aHttpResponse, aRequestScopeInitializer.getRequestScope ()); } finally { s_aTimerHdlTrace.addTime (aSW.stopAndGetMillis ()); aRequestScopeInitializer.destroyScope (); } } }
final StopWatch aSW = StopWatch.createdStarted (); throw new DAOException ("Failed to write DAO XML data to file"); m_aStatsCounterWriteTimer.addTime (aSW.stopAndGetMillis ()); m_aStatsCounterWriteSuccess.increment (); m_nWriteCount++;