Package com.ecyrd.speed4j

Examples of com.ecyrd.speed4j.StopWatch


     */
    private void doLog(long lastRun, long finalMoment)
    {
        if( m_log == null || !m_log.isInfoEnabled() ) return;
       
        StopWatch sw;
       
        m_statistics = new HashMap<String,CollectedStatistics>();
       
        // Peek at the queue and see if there is someone there.
        while( null != (sw = m_queue.peek()) )
        {
            if( sw.getCreationTime() > finalMoment )
            {
                break;
            }
           
            // Remove the object from the head of the queue.
            m_queue.remove();
           
            CollectedStatistics cs = m_statistics.get(sw.getTag());
           
            if( cs == null )
            {
                cs = new CollectedStatistics();
                m_statistics.put( sw.getTag(), cs );
            }
           
            cs.add( sw );
        }
       
View Full Code Here


     @return true, if the queue is not emptied and there are events
     *          in it where the finalMoment is achieved.
     */
    private boolean emptyQueue(long finalMoment)
    {
        StopWatch sw;

        try
        {
            while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
            {
                if( sw.getCreationTime() > finalMoment )
                {
                    // Return this one back in the queue; as it belongs to the
                    // next period already.
                    m_queue.addFirst(sw);
                    return true;
                }

                CollectedStatistics cs = m_stats.get(sw.getTag());

                if( cs == null )
                {
                    cs = new CollectedStatistics();
                    m_stats.put( sw.getTag(), cs );
                }

                cs.add( sw );
               
                //
                //  Do the logging to the slowlog as well, if it's defined
                //  and we bypass the threshold.
                //
                //  TODO: Using String.format to get the ISO date isn't very fast. Need to figure out a better method.
                //
                if( m_slowLogOn && m_slowLog != null )
                {
                    Long threshold = m_slowThresholdMicros.get( sw.getTag() );
                    if( threshold != null && sw.getTimeMicros() > threshold )
                    {
                        m_slowLog.info( "{} {} \"{}\" \"{}\" {}", new Object[] {
                                        String.format("%tFT%<tT.%<tL%<tz",new Date(sw.getCreationTime())),
                                        saneDoubleToString( m_slowLogPercentile ),
                                        sw.getTag(),
                                        sw.getMessage() != null ? sw.getMessage() : "",
                                        sw.getTimeMicros()/1000F } );
                    }
                }
            }
        }
        catch( InterruptedException e ) {} // Just return immediately
View Full Code Here

     @return true, if the queue is not emptied and there are events
     *          in it where the finalMoment is achieved.
     */
    private boolean emptyQueue(long finalMoment)
    {
        StopWatch sw;

        try
        {
            while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
            {
                if( sw.getCreationTime() > finalMoment )
                {
                    // Return this one back in the queue; as it belongs to the
                    // next period already.
                    m_queue.addFirst(sw);
                    return true;
                }

                CollectedStatistics cs = m_stats.get(sw.getTag());

                if( cs == null )
                {
                    cs = new CollectedStatistics();
                    m_stats.put( sw.getTag(), cs );
                }

                cs.add( sw );
            }
        }
View Full Code Here

     */
    private void doLog(long lastRun)
    {
        if( m_log == null || !m_log.isInfoEnabled() ) return;
       
        StopWatch sw;
       
        m_statistics = new HashMap<String,CollectedStatistics>();
       
        while( null != (sw = m_queue.poll()) )
        {
            CollectedStatistics cs = m_statistics.get(sw.getTag());
           
            if( cs == null )
            {
                cs = new CollectedStatistics();
                m_statistics.put( sw.getTag(), cs );
            }
           
            cs.add( sw );
        }
       
View Full Code Here

     */
    private void doLog(long lastRun)
    {
        if( m_log == null || !m_log.isInfoEnabled() ) return;
       
        StopWatch sw;
       
        m_statistics = new HashMap<String,CollectedStatistics>();
       
        while( null != (sw = m_queue.poll()) )
        {
            CollectedStatistics cs = m_statistics.get(sw.getTag());
           
            if( cs == null )
            {
                cs = new CollectedStatistics();
                m_statistics.put( sw.getTag(), cs );
            }
           
            cs.add( sw );
        }
       
View Full Code Here

     @return true, if the queue is not emptied and there are events
     *          in it where the finalMoment is achieved.
     */
    private boolean emptyQueue(long finalMoment)
    {
        StopWatch sw;
       
        try
        {
            while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
            {
                if( sw.getCreationTime() > finalMoment )
                {
                    // Return this one back in the queue; as it belongs to the
                    // next period already.
                    m_queue.addFirst(sw);
                    return true;
                }
           
                CollectedStatistics cs = m_stats.get(sw.getTag());
           
                if( cs == null )
                {
                    cs = new CollectedStatistics();
                    m_stats.put( sw.getTag(), cs );
                }
           
                cs.add( sw );
            }
        }
View Full Code Here

     */
    private void doLog(long lastRun, long finalMoment)
    {
        if( m_log == null || !m_log.isInfoEnabled() ) return;
       
        StopWatch sw;
       
        m_statistics = new HashMap<String,CollectedStatistics>();
       
        // Peek at the queue and see if there is someone there.
        while( null != (sw = m_queue.peek()) )
        {
            if( sw.getCreationTime() > finalMoment )
            {
                break;
            }
           
            // Remove the object from the head of the queue.
            m_queue.remove();
           
            CollectedStatistics cs = m_statistics.get(sw.getTag());
           
            if( cs == null )
            {
                cs = new CollectedStatistics();
                m_statistics.put( sw.getTag(), cs );
            }
           
            cs.add( sw );
        }
       
View Full Code Here

TOP

Related Classes of com.ecyrd.speed4j.StopWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.