类org.slf4j.profiler.Profiler源码实例Demo

下面列出了怎么用org.slf4j.profiler.Profiler的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: light   文件: ServiceLocator.java
/**
 * Get configuration map by the name of the config. The file will only be loaded from file system
 * the first time.
 *
 * @param configName
 * @return
 */
public Map<String, Object> getJsonMapConfig(String configName) {
    logger.entry(configName);
    audit.info("getConfig for {}", configName);
    Profiler profiler = new Profiler(ServiceLocator.class.getName());
    profiler.setLogger(logger);
    profiler.start("getConfig");
    Map<String, Object> config = (Map<String, Object>)configImage.get(configName);
    if(config == null) {
        synchronized (ServiceLocator.class) {
            config = (Map<String, Object>)configImage.get(configName);
            if(config == null) {
                config = loadJsonMapConfig(configName);
                if(config != null) configImage.put(configName, config);
            }
        }
    }
    profiler.stop().log();
    logger.exit(config);
    return config;
}
 
源代码2 项目: tutorials   文件: SimpleController.java
@GetMapping("/slf4j-guide-profiler-request")
public String clientProfilerRequest() {
    logger.info("client has made a request");
    Profiler myProfiler = new Profiler("MYPROFILER");
    // Associate the logger to handle the output( for testing purposes here)
    myProfiler.setLogger(logger);

    myProfiler.start("List generation process");
    List<Integer> list = generateList();

    myProfiler.start("List sorting process");
    Collections.sort(list);

    // Use the log() method instead of print() to use the logger (for testing purposes here)
    myProfiler.stop()
        .log();
    return "finished";
}
 
源代码3 项目: neoscada   文件: HistoricalItemImpl.java
@Override
public synchronized Query createQuery ( final QueryParameters parameters, final QueryListener listener, final boolean updateData )
{
    final Profiler p = new Profiler ( "hi.createQuery" );
    p.setLogger ( logger );

    if ( this.service == null )
    {
        logger.warn ( "We have no service. We cannot create a query" );
        return null;
    }

    p.start ( "call shi.createQuery" );

    final WrapperQuery query = new WrapperQuery ( this.service.createQuery ( parameters, listener, updateData ) );
    if ( query.isValid () )
    {
        this.openQueries.add ( query );
    }
    else
    {
        logger.warn ( "We have an invalid query" );
    }

    p.stop ().log ();

    return query;
}
 
源代码4 项目: neoscada   文件: ServerConnectionImpl.java
protected synchronized void handleCloseQuery ( final CloseQuery message )
{
    final Profiler p = new Profiler ( "Close Query" );
    p.setLogger ( logger );

    p.start ( "init" );

    // get the query id
    final long queryId = message.getQueryId ();

    logger.info ( "Handle close query: {}", queryId );

    final QueryHandler handler;

    p.start ( "remove" );

    sendQueryState ( queryId, QueryState.DISCONNECTED );
    handler = this.queries.remove ( queryId );

    // close outside of lock
    if ( handler != null )
    {
        p.start ( "Close" );
        // throw it in the disposer queue ... the storage module takes too long
        this.queryDisposer.execute ( new Runnable () {

            @Override
            public void run ()
            {
                logger.info ( "Disposing query {} ...", queryId );
                handler.close ();
                logger.info ( "Disposing query {} ... done!", queryId );
            }
        } );
    }

    p.stop ().log ();
}
 
源代码5 项目: neoscada   文件: ServerConnectionImpl.java
protected void handleCreateQuery ( final CreateQuery message )
{
    final Profiler p = new Profiler ( "Create query" );
    p.setLogger ( logger );

    // get the query id
    final long queryId = message.getQueryId ();

    logger.debug ( "Creating new query with id: {}", queryId );

    try
    {
        p.start ( "Prepare" );

        // get the query item
        final String itemId = message.getItemId ();
        // get the initial query parameters
        final QueryParameters parameters = message.getQueryParameters ();
        final boolean updateData = message.isUpdateData ();

        p.start ( "Make query" );
        makeQuery ( message, queryId, itemId, parameters, updateData );

        p.start ( "Finish" );
    }
    catch ( final Throwable e )
    {
        sendQueryState ( queryId, QueryState.DISCONNECTED );
    }
    finally
    {
        p.stop ().log ();
    }
}
 
源代码6 项目: neoscada   文件: MergeQualityData.java
public void merge ()
{
    this.data = new WritableSeriesData ();

    if ( this.width <= 0 || this.startTimestamp >= this.endTimestamp )
    {
        logger.debug ( "Skip merge - width: {}, start: {}, end: {}", this.width, this.startTimestamp, this.endTimestamp );
        return;
    }

    final Profiler p = new Profiler ( "Merge" ); //$NON-NLS-1$
    p.setLogger ( logger );

    final long start = System.currentTimeMillis ();

    try
    {
        p.start ( "Init" ); //$NON-NLS-1$
        final Entry[] data = new Entry[this.width];

        final long diff = this.endTimestamp - this.startTimestamp;
        final double step = (double)diff / (double)this.width;
        double c = 0.0;

        for ( int i = 0; i < data.length; i++ )
        {
            data[i] = new Entry ();
            data[i].timestamp = this.startTimestamp + (long)c;
            c += step;
        }

        p.start ( "Perform merge" ); //$NON-NLS-1$
        performMerge ( data, step );

        p.start ( "Convert" ); //$NON-NLS-1$
        for ( final Entry entry : data )
        {
            this.data.add ( new DataEntry ( entry.timestamp, entry.value ) );
        }
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to merge data", e ); //$NON-NLS-1$
    }
    finally
    {
        p.stop ();

        final boolean tooLong = System.currentTimeMillis () - start > 10 * 1000;

        if ( tooLong || logger.isTraceEnabled () )
        {
            p.log ();
        }
    }
}
 
源代码7 项目: neoscada   文件: ServiceImpl.java
@Override
public Query createQuery ( final Session session, final String itemId, final QueryParameters parameters, final QueryListener listener, final boolean updateData ) throws InvalidSessionException, InvalidItemException
{
    final Profiler p = new Profiler ( "createQuery" );
    p.setLogger ( logger );

    p.start ( "Validate session" );
    final SessionImpl sessionImpl = validateSession ( session, SessionImpl.class );

    try
    {
        synchronized ( this )
        {
            p.start ( "Get item" );

            final HistoricalItem item = this.items.get ( itemId );
            if ( item == null )
            {
                throw new InvalidItemException ( itemId );
            }
            p.start ( "new Query" );
            final QueryImpl queryImpl = new QueryImpl ( sessionImpl, listener );
            p.start ( "createQuery" );
            final Query query = item.createQuery ( parameters, queryImpl, updateData );
            p.start ( "Completing" );

            if ( query != null )
            {
                queryImpl.setQuery ( query );
                return queryImpl;
            }
            else
            {
                logger.warn ( "Unable to create query: {}", itemId );
                return null;
            }
        }
    }
    finally
    {
        p.stop ().log ();
    }
}
 
源代码8 项目: han3_ji7_tsoo1_kian3   文件: IDSrendService.java
/**
 * 組字而且畫出來。
 * 
 * @param 組字式
 *            使用者要求的組字式
 * @param 欲畫的所在
 *            畫字體的所在
 * @return 實際畫的組字式
 */
public String 組字(String 組字式, Graphics 欲畫的所在)
{
	if (組字式.length() >= 組字式上大長度)
		組字式 = 組字式.substring(0, 組字式上大長度);
	Profiler 看時工具 = new Profiler("組字 " + 組字式);
	看時工具.setLogger(記錄工具);

	看時工具.start("初使化");
	// 記錄工具.debug(MarkerFactory.getMarker("@@"),
	// "初使化~~ 時間:" + System.currentTimeMillis());

	看時工具.start("分析中");
	// 記錄工具.debug("分析中~~ 時間:" + System.currentTimeMillis());

	IDSParser 序列分析工具 = new IDSParser(組字式, 查詢方式);
	CharComponent CharComponent;
	try
	{
		CharComponent = 序列分析工具.解析一個組字式();
	}
	catch (IDSExecption e)
	{
		// TODO 看欲按怎處理,硬顯示,抑是傳連結毋著?
		e.printStackTrace();
		return "";
	}

	CharComponent 組字部件 = (CharComponent) CharComponent;
	// 組字部件.建立組字式(組字式建立工具);
	// 記錄工具.debug(組字部件.提到組字式());
	CharComponent = (CharComponent) 正規化工具.正規化(代換工具.三元素組合代換成二元素(CharComponent));
	組字部件.樹狀結構組字式();
	// 記錄工具.debug(組字部件.提到組字式());

	看時工具.start("設定中");
	// 記錄工具.debug("設定中~~ 時間:" + System.currentTimeMillis());

	ChineseCharCompositeMoveabletype 活字 = CharComponent.typeset(設定工具, null);

	看時工具.start("調整中");
	// 記錄工具.debug("調整中~~ 時間:" + System.currentTimeMillis());

	活字.adjust(調整工具);

	看時工具.start("四角中");
	SeprateMovabletype 上尾欲畫的圖 = 調整工具.format((PieceMovableType) 活字);

	看時工具.start("加粗中");
	活字加粗.加粗(上尾欲畫的圖);

	看時工具.start("列印中");
	// 記錄工具.debug("列印中~~ 時間:" + System.currentTimeMillis());
	Graphics2D 字型圖版 = (Graphics2D) 欲畫的所在;
	字型圖版.setColor(Color.black);
	字型圖版.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	字型圖版.translate(0, 字型大細 * 0.83);// TODO 閣愛研究按怎調整
	字型圖版.setStroke(new NullStroke());

	AwtForSinglePiecePrinter 列印工具 = new AwtForSinglePiecePrinter(字型圖版);

	列印工具.printPiece(上尾欲畫的圖);

	看時工具.stop().log();
	return 組字部件.樹狀結構組字式();
}