• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Slf4JStopWatch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.perf4j.slf4j.Slf4JStopWatch的典型用法代码示例。如果您正苦于以下问题:Java Slf4JStopWatch类的具体用法?Java Slf4JStopWatch怎么用?Java Slf4JStopWatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Slf4JStopWatch类属于org.perf4j.slf4j包,在下文中一共展示了Slf4JStopWatch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getPixels

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
/**
 * Retrieves a single {@link Pixels} from the server.
 * @param client OMERO client to use for querying.
 * @param imageId {@link Image} identifier to query for.
 * @return Loaded {@link Pixels} or <code>null</code> if it does not exist.
 * @throws ServerError If there was any sort of error retrieving the pixels.
 */
protected Pixels getPixels(omero.client client, Long imageId)
        throws ServerError {
    Map<String, String> ctx = new HashMap<String, String>();
    ctx.put("omero.group", "-1");
    ParametersI params = new ParametersI();
    params.addId(imageId);
    StopWatch t0 = new Slf4JStopWatch("getPixels");
    try {
        return (Pixels) client.getSession().getQueryService().findByQuery(
            "SELECT p FROM Pixels as p " +
            "JOIN FETCH p.image " +
            "JOIN FETCH p.pixelsType " +
            "WHERE p.image.id = :id",
            params, ctx
        );
    } finally {
        t0.stop();
    }
}
 
开发者ID:glencoesoftware,项目名称:omero-ms-pixel-buffer,代码行数:27,代码来源:TileRequestHandler.java


示例2: init

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected void init() {
    StopWatch initTiming = new Slf4JStopWatch("ViewRepository.init." + getClass().getSimpleName());

    storage.clear();
    readFileNames.clear();

    String configName = AppContext.getProperty("cuba.viewsConfig");
    if (!StringUtils.isBlank(configName)) {
        Element rootElem = DocumentHelper.createDocument().addElement("views");

        StrTokenizer tokenizer = new StrTokenizer(configName);
        for (String fileName : tokenizer.getTokenArray()) {
            addFile(rootElem, fileName);
        }

        checkDuplicates(rootElem);

        for (Element viewElem : Dom4j.elements(rootElem, "view")) {
            deployView(rootElem, viewElem, new HashSet<>());
        }
    }

    initTiming.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:AbstractViewRepository.java


示例3: loadData

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("TDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));

    clear();

    this.tree = loadTree(params);

    Map<K, Node<T>> targetNodes = new HashMap<>();
    if (tree != null) {
        for (Node<T> node : tree.toList()) {
            final T entity = node.getData();
            final K id = entity.getId();

            data.put(id, entity);
            attachListener(entity);

            targetNodes.put(id, node);
        }
    }

    this.nodes = targetNodes;

    sw.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:AbstractTreeDatasource.java


示例4: loadData

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
/**
 * Load data from middleware into {@link #data} field.
 * <p>In case of error sets {@link #dataLoadError} field to the exception object.</p>
 * @param params    datasource parameters, as described in {@link CollectionDatasource#refresh(java.util.Map)}
 */
protected void loadData(Map<String, Object> params) {
    Security security = AppBeans.get(Security.NAME);
    if (!security.isEntityOpPermitted(metaClass, EntityOp.READ)) {
        return;
    }

    String tag = getLoggingTag("CDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));

    if (needLoading()) {
        LoadContext context = beforeLoadData(params);
        if (context == null) {
            return;
        }
        try {
            final Collection<T> entities = dataSupplier.loadList(context);

            afterLoadData(params, context, entities);
        } catch (Throwable e) {
            dataLoadError = e;
        }
    }

    sw.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:31,代码来源:CollectionDatasourceImpl.java


示例5: execute

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
public void execute(Context context, Frame window) {
    if (wrapped) {
        String loggingId = ComponentsHelper.getFullFrameId(this.frame);

        if (this.frame instanceof AbstractFrame) {
            StopWatch initStopWatch = new Slf4JStopWatch(loggingId + "#" +
                    UIPerformanceLogger.LifeCycle.INIT,
                    LoggerFactory.getLogger(UIPerformanceLogger.class));

            ((AbstractFrame) this.frame).init(params);

            initStopWatch.stop();
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:FrameLoader.java


示例6: createWindow

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected Window createWindow(WindowInfo windowInfo, Map<String, Object> params) {
    Window window;
    try {
        window = (Window) windowInfo.getScreenClass().newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException("Unable to instantiate window class", e);
    }

    window.setId(windowInfo.getId());
    window.setWindowManager(this);

    init(window, params);

    StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" +
            LifeCycle.UI_PERMISSIONS,
            LoggerFactory.getLogger(UIPerformanceLogger.class));

    // apply ui permissions
    WindowCreationHelper.applyUiPermissions(window);

    uiPermissionsWatch.stop();

    return window;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:WindowManager.java


示例7: afterShowWindow

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected void afterShowWindow(Window window) {
    if (!WindowParams.DISABLE_APPLY_SETTINGS.getBool(window.getContext())) {
        window.applySettings(getSettingsImpl(window.getId()));
    }
    if (!WindowParams.DISABLE_RESUME_SUSPENDED.getBool(window.getContext())) {
        ((DsContextImplementation) window.getDsContext()).resumeSuspended();
    }

    if (window instanceof AbstractWindow) {
        AbstractWindow abstractWindow = (AbstractWindow) window;

        if (abstractWindow.isAttributeAccessControlEnabled()) {
            AttributeAccessSupport attributeAccessSupport = AppBeans.get(AttributeAccessSupport.NAME);
            attributeAccessSupport.applyAttributeAccess(abstractWindow, false);
        }

        StopWatch readyStopWatch = new Slf4JStopWatch(window.getId() + "#" +
                LifeCycle.READY,
                LoggerFactory.getLogger(UIPerformanceLogger.class));

        abstractWindow.ready();

        readyStopWatch.stop();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:WindowManager.java


示例8: processScheduledTasks

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
public void processScheduledTasks(boolean onlyIfActive) {
    if (onlyIfActive && !isActive())
        return;

    log.debug("Processing scheduled tasks");
    if (schedulingStartTime == 0)
        schedulingStartTime = timeSource.currentTimeMillis();

    authentication.begin();
    try {
        StopWatch sw = new Slf4JStopWatch("Scheduling.processTasks");
        Coordinator.Context context = coordinator.begin();
        try {
            for (ScheduledTask task : context.getTasks()) {
                processTask(task);
            }
        } finally {
            coordinator.end(context);
        }
        sw.stop();
    } finally {
        authentication.end();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:Scheduling.java


示例9: calculateNextCronDate

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected long calculateNextCronDate(ScheduledTask task, long date, long currentDate, long frame) {
    StopWatch sw = new Slf4JStopWatch("Cron next date calculations");
    CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(task.getCron(), getCurrentTimeZone());
    //if last start = 0 (task never has run) or to far in the past, we use (NOW - FRAME) timestamp for pivot time
    //this approach should work fine cause cron works with absolute time
    long pivotPreviousTime = Math.max(date, currentDate - frame);

    Date currentStart = null;
    Date nextDate = cronSequenceGenerator.next(new Date(pivotPreviousTime));
    while (nextDate.getTime() < currentDate) {//if next date is in past try to find next date nearest to now
        currentStart = nextDate;
        nextDate = cronSequenceGenerator.next(nextDate);
    }

    if (currentStart == null) {
        currentStart = nextDate;
    }
    log.trace("{}\n now={} frame={} currentStart={} lastStart={} cron={}",
            task, currentDate, frame, currentStart, task.getCron());
    sw.stop();
    return currentStart.getTime();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:Scheduling.java


示例10: internalSend

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected void internalSend(Serializable message, boolean sync) {
    StopWatch sw = new Slf4JStopWatch(String.format("sendClusterMessage(%s)", message.getClass().getSimpleName()));
    try {
        byte[] bytes = SerializationSupport.serialize(message);
        log.debug("Sending message: {}: {} ({} bytes)", message.getClass(), message, bytes.length);
        MessageStat stat = messagesStat.get(message.getClass().getName());
        if (stat != null) {
            stat.updateSent(bytes.length);
        }
        Message msg = new Message(null, null, bytes);
        if (sync) {
            msg.setFlag(Message.Flag.RSVP);
        }
        try {
            channel.send(msg);
        } catch (Exception e) {
            log.error("Error sending message", e);
        }
    } finally {
        sw.stop();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:ClusterManager.java


示例11: receive

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
public void receive(Message msg) {
    byte[] bytes = msg.getBuffer();
    if (bytes == null) {
        log.debug("Null buffer received");
        return;
    }
    StopWatch sw = new Slf4JStopWatch();
    String simpleClassName = null;
    try {
        Serializable data = (Serializable) SerializationSupport.deserialize(bytes);
        String className = data.getClass().getName();
        simpleClassName = data.getClass().getSimpleName();
        log.debug("Received message: {}: {} ({} bytes)", data.getClass(), data, bytes.length);
        MessageStat stat = messagesStat.get(className);
        if (stat != null) {
            stat.updateReceived(bytes.length);
        }
        ClusterListener listener = listeners.get(className);
        if (listener != null) {
            listener.receive(data);
        }
    } finally {
        sw.stop(String.format("receiveClusterMessage(%s)", simpleClassName));
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:ClusterManager.java


示例12: getPixelBuffer

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected PixelBuffer getPixelBuffer(Pixels pixels)
        throws ApiUsageException {
    StopWatch t0 = new Slf4JStopWatch("getPixelBuffer");
    try {
        return pixelsService.getPixelBuffer(
                (ome.model.core.Pixels) mapper.reverse(pixels), false);
    } finally {
        t0.stop();
    }
}
 
开发者ID:glencoesoftware,项目名称:omero-ms-pixel-buffer,代码行数:11,代码来源:TileRequestHandler.java


示例13: loadData

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("CDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));

    detachListener(data.values());
    data.clear();

    for (JmxInstance jmxInstance : jmxControlAPI.getInstances()) {
        data.put(jmxInstance.getId(), jmxInstance);
        attachListener(jmxInstance);
    }

    sw.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:16,代码来源:JmxInstancesDatasource.java


示例14: replaceOverridden

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected void replaceOverridden(View replacementView) {
    StopWatch replaceTiming = new Slf4JStopWatch("ViewRepository.replaceOverridden");

    HashSet<View> checked = new HashSet<>();

    for (View view : getAllInitialized()) {
        if (!checked.contains(view)) {
            replaceOverridden(view, replacementView, checked);
        }
    }

    replaceTiming.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:AbstractViewRepository.java


示例15: searchFiles

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected String searchFiles(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
    StopWatch stopWatch = new Slf4JStopWatch("Messages.searchFiles");
    try {
        String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);

        String msg = strCache.get(cacheKey);
        if (msg != null)
            return msg;

        log.trace("searchFiles: " + cacheKey);

        String packPath = confDir + "/" + pack.replaceAll("\\.", "/");
        while (packPath != null && !packPath.equals(confDir)) {
            Properties properties = loadPropertiesFromFile(packPath, locale, truncatedLocale);
            if (properties != PROPERTIES_NOT_FOUND) {
                msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
                if (msg != null)
                    return msg;
            }
            // not found, keep searching
            int pos = packPath.lastIndexOf("/");
            if (pos < 0)
                packPath = null;
            else
                packPath = packPath.substring(0, pos);
        }
        return null;
    } finally {
        stopWatch.stop();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:32,代码来源:AbstractMessages.java


示例16: searchClasspath

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected String searchClasspath(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
    StopWatch stopWatch = new Slf4JStopWatch("Messages.searchClasspath");
    try {
        String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);

        String msg = strCache.get(cacheKey);
        if (msg != null)
            return msg;

        log.trace("searchClasspath: " + cacheKey);

        String packPath = "/" + pack.replaceAll("\\.", "/");
        while (packPath != null) {
            Properties properties = loadPropertiesFromResource(packPath, locale, truncatedLocale);
            if (properties != PROPERTIES_NOT_FOUND) {
                msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
                if (msg != null)
                    return msg;
            }
            // not found, keep searching
            int pos = packPath.lastIndexOf("/");
            if (pos < 0)
                packPath = null;
            else
                packPath = packPath.substring(0, pos);
        }
        return null;
    } finally {
        stopWatch.stop();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:32,代码来源:AbstractMessages.java


示例17: searchRemotely

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
protected String searchRemotely(String pack, String key, Locale locale) {
    if (!remoteSearch || !AppContext.isStarted())
        return null;

    if (log.isTraceEnabled())
        log.trace("searchRemotely: " + pack + "/" + locale + "/" + key);

    StopWatch stopWatch = new Slf4JStopWatch("Messages.searchRemotely");
    try {
        String message = localizedMessageService.getMessage(pack, key, locale);
        if (key.equals(message))
            return null;
        else
            return message;
    } catch (Exception e) {
        List list = ExceptionUtils.getThrowableList(e);
        for (Object throwable : list) {
            if (throwable instanceof SocketException) {
                log.trace("searchRemotely: " + throwable);
                return null; // silently ignore network errors
            }
        }
        throw (RuntimeException) e;
    } finally {
        stopWatch.stop();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:29,代码来源:MessagesClientImpl.java


示例18: getCellComponent

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
protected Component getCellComponent(int row) {
    Entity item = desktopAbstractTable.getTableModel().getItem(row);

    StopWatch sw = new Slf4JStopWatch("TableColumnGenerator." + desktopAbstractTable.getId());
    @SuppressWarnings("unchecked")
    com.haulmont.cuba.gui.components.Component component = columnGenerator.generateCell(item);
    sw.stop();

    Component comp;
    if (component == null) {
        comp = new JLabel("");
    } else if (component instanceof Table.PlainTextCell) {
        comp = new JLabel(((Table.PlainTextCell) component).getText());
    } else {
        if (component instanceof BelongToFrame) {
            BelongToFrame belongToFrame = (BelongToFrame) component;
            if (belongToFrame.getFrame() == null) {
                belongToFrame.setFrame(desktopAbstractTable.getFrame());
            }
        }
        component.setParent(desktopAbstractTable);

        JComponent jComposition = DesktopComponentsHelper.getComposition(component);
        jComposition.putClientProperty(CELL_EDITOR_TABLE, desktopAbstractTable.getComponent());
        jComposition.putClientProperty(CELL_COMPONENT, component);

        comp = jComposition;
    }

    cache.put(row, comp);
    return comp;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:33,代码来源:DesktopTableCellEditor.java


示例19: loadData

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("VHDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));

    delegate.loadData(params);

    sw.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:10,代码来源:ValueHierarchicalDatasourceImpl.java


示例20: loadData

import org.perf4j.slf4j.Slf4JStopWatch; //导入依赖的package包/类
@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("VGDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));

    delegate.loadData(params);

    sw.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:10,代码来源:ValueGroupDatasourceImpl.java



注:本文中的org.perf4j.slf4j.Slf4JStopWatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SineOscillator类代码示例发布时间:2022-05-22
下一篇:
Java EntityWitch类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap