Tabnine Logo
StopWatch
Code IndexAdd Tabnine to your IDE (free)

How to use
StopWatch
in
com.helger.commons.timing

Best Java code snippets using com.helger.commons.timing.StopWatch (Showing top 20 results out of 315)

origin: com.helger/peppol-directory-indexer

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");
 }
}
origin: com.helger/ph-db-jpa

                               @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 ());
origin: com.helger/ph-webscopes

@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 ();
 }
}
origin: phax/as2-lib

final StopWatch aSW = StopWatch.createdStarted ();
DataSource aMsgDataSource = null;
try
aSW.stop ();
origin: com.helger/ph-xservlet

public void beforeRequest (@Nonnull final IRequestWebScope aRequestScope)
{
 m_aSW = StopWatch.createdStarted ();
}
origin: com.helger/ph-xservlet

 public void afterRequest (@Nonnull final IRequestWebScope aRequestScope)
 {
  // Timer per HTTP method
  m_aTimer.addTime (aRequestScope.getHttpMethod ().getName (), m_aSW.stopAndGetMillis ());
 }
}
origin: phax/as2-lib

final StopWatch aSW = StopWatch.createdStarted ();
try
 LOGGER.debug ("Response retrieved: " + aResponse.getAsString ());
aResponse.setExecutionDuration (aSW.stopAndGetDuration ());
return aResponse;
origin: phax/as2-lib

@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 ();
}
origin: phax/as2-lib

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 ());
origin: com.helger/ph-oton-core

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");
}
origin: com.helger/ph-db-jpa

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 ());
origin: com.helger/ph-webscopes

@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 ();
 }
}
origin: phax/as2-lib

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 ());
origin: com.helger/ph-xml

final StopWatch aSW = StopWatch.createdStarted ();
final ThreadDescriptorList ret = new ThreadDescriptorList ();
try
 final long nMillis = aSW.stopAndGetMillis ();
 if (nMillis > 1000)
  if (LOGGER.isWarnEnabled ())
origin: com.helger/ph-webscopes

@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 ();
 }
}
origin: com.helger/ph-dao

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++;
origin: com.helger/ph-webscopes

@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 ();
 }
}
origin: com.helger/ph-xml

try
 final StopWatch aSW = StopWatch.createdStarted ();
 DocumentBuilder aDocumentBuilder;
 boolean bFromPool = false;
   s_aDomTimerHdl.addTime (aSW.stopAndGetMillis ());
  else
   s_aDomSchemaTimerHdl.addTime (aSW.stopAndGetMillis ());
origin: com.helger/ph-webscopes

 @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 ();
  }
 }
}
origin: com.helger/ph-dao

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++;
com.helger.commons.timingStopWatch

Most used methods

  • createdStarted
  • stopAndGetMillis
  • getMillis
  • <init>
  • stop
  • stopAndGetDuration

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now