Search in sources :

Example 16 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.

the class Scheduling method processScheduledTasks.

@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();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 17 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.

the class ManagedBeanInfoDatasource method loadTree.

@Override
protected Tree<ManagedBeanInfo> loadTree(Map<String, Object> params) {
    String tag = getLoggingTag("TDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    List<Node<ManagedBeanInfo>> nodes = new ArrayList<>();
    if (jmxInstance != null) {
        List<ManagedBeanDomain> domains = jmxControlAPI.getDomains(jmxInstance);
        Map<String, Node<ManagedBeanInfo>> domainMap = new HashMap<>();
        for (ManagedBeanDomain mbd : domains) {
            ManagedBeanInfo dummy = metadata.create(ManagedBeanInfo.class);
            dummy.setDomain(mbd.getName());
            Node<ManagedBeanInfo> node = new Node<>(dummy);
            domainMap.put(mbd.getName(), node);
            nodes.add(node);
        }
        List<ManagedBeanInfo> list = loadManagedBeans(params);
        for (ManagedBeanInfo mbi : list) {
            if (mbi != null) {
                if (domainMap.containsKey(mbi.getDomain())) {
                    domainMap.get(mbi.getDomain()).addChild(new Node<>(mbi));
                }
            }
        }
        // remove root nodes that might have left without children after filtering
        for (Node<ManagedBeanInfo> rootNode : new ArrayList<>(nodes)) {
            if (rootNode.getChildren().isEmpty()) {
                nodes.remove(rootNode);
            }
        }
    }
    sw.stop();
    return new Tree<>(nodes);
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Node(com.haulmont.bali.datastruct.Node) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) ManagedBeanDomain(com.haulmont.cuba.web.jmx.entity.ManagedBeanDomain) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Tree(com.haulmont.bali.datastruct.Tree)

Example 18 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project bioformats by openmicroscopy.

the class OpenBytesPerformanceTest method setId.

@Test
public void setId() throws Exception {
    reader = new ImageReader();
    reader = new ChannelFiller(reader);
    reader = new ChannelSeparator(reader);
    reader = new MinMaxCalculator(reader);
    if (memMap && reader.isSingleFile(id)) {
        TestTools.mapFile(id);
    }
    StopWatch stopWatch = new Slf4JStopWatch();
    reader.setId(id);
    stopWatch.stop(String.format("%s.setId.%s", ((ReaderWrapper) reader).unwrap().getClass().getName(), filename));
    seriesCount = reader.getSeriesCount();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelFiller(loci.formats.ChannelFiller) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) ReaderWrapper(loci.formats.ReaderWrapper) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Test(org.testng.annotations.Test)

Example 19 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.

the class WindowManager method openFrame.

public Frame openFrame(Frame parentFrame, Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
    if (params == null) {
        params = Collections.emptyMap();
    }
    // Parameters can be useful later
    params = createParametersMap(windowInfo, params);
    String src = windowInfo.getTemplate();
    ComponentLoaderContext context = new ComponentLoaderContext(params);
    context.setDsContext(parentFrame.getDsContext());
    context.setFullFrameId(windowInfo.getId());
    context.setCurrentFrameId(windowInfo.getId());
    LayoutLoader loader = new LayoutLoader(context, AppConfig.getFactory(), LayoutLoaderConfig.getFrameLoaders());
    loader.setLocale(getLocale());
    loader.setMessagesPack(parentFrame.getMessagesPack());
    StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
    Frame component;
    String frameId = id != null ? id : windowInfo.getId();
    Pair<ComponentLoader, Element> loaderElementPair = loader.createFrameComponent(src, frameId, context.getParams());
    component = (Frame) loaderElementPair.getFirst().getResultComponent();
    if (parent != null) {
        showFrame(parent, component);
    } else {
        component.setFrame(parentFrame);
    }
    loaderElementPair.getFirst().loadComponent();
    if (component.getMessagesPack() == null) {
        component.setMessagesPack(parentFrame.getMessagesPack());
    }
    context.executeInjectTasks();
    context.setFrame(component);
    context.executePostWrapTasks();
    // init of frame
    context.executeInitTasks();
    context.executePostInitTasks();
    loadDescriptorWatch.stop();
    initDebugIds(component);
    userActionsLog.trace("Frame {} was opened", windowInfo.getId());
    return component;
}
Also used : LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Element(org.dom4j.Element) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Example 20 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.

the class WindowManager method createWindow.

protected Window createWindow(WindowInfo windowInfo, OpenType openType, Map<String, Object> params, LayoutLoaderConfig layoutConfig, boolean topLevel) {
    if (!topLevel) {
        checkPermission(windowInfo);
    }
    StopWatch loadDescriptorWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.LOAD, LoggerFactory.getLogger(UIPerformanceLogger.class));
    Element element = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), params);
    // try to load main screen class to resolve dynamic compilation dependencies issues
    preloadMainScreenClass(element);
    ComponentLoaderContext componentLoaderContext = new ComponentLoaderContext(params);
    componentLoaderContext.setFullFrameId(windowInfo.getId());
    componentLoaderContext.setCurrentFrameId(windowInfo.getId());
    ComponentLoader windowLoader = createLayout(windowInfo, element, componentLoaderContext, layoutConfig);
    Window clientSpecificWindow = (Window) windowLoader.getResultComponent();
    Window windowWrapper = wrapByCustomClass(clientSpecificWindow, element);
    screenViewsLoader.deployViews(element);
    DsContext dsContext = loadDsContext(element);
    initDatasources(clientSpecificWindow, dsContext, params);
    componentLoaderContext.setDsContext(dsContext);
    WindowContext windowContext = new WindowContextImpl(clientSpecificWindow, openType, params);
    clientSpecificWindow.setContext(windowContext);
    dsContext.setFrameContext(windowContext);
    // noinspection unchecked
    windowLoader.loadComponent();
    clientSpecificWindow.setWindowManager(this);
    loadDescriptorWatch.stop();
    initWrapperFrame(windowWrapper, componentLoaderContext, element, params);
    componentLoaderContext.setFrame(windowWrapper);
    componentLoaderContext.executePostInitTasks();
    if (configuration.getConfig(GlobalConfig.class).getTestMode()) {
        initDebugIds(clientSpecificWindow);
    }
    StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.UI_PERMISSIONS, LoggerFactory.getLogger(UIPerformanceLogger.class));
    // apply ui permissions
    WindowCreationHelper.applyUiPermissions(clientSpecificWindow);
    uiPermissionsWatch.stop();
    return windowWrapper;
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) DsContext(com.haulmont.cuba.gui.data.DsContext) Element(org.dom4j.Element) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader)

Aggregations

StopWatch (org.perf4j.StopWatch)37 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)37 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)17 Element (org.dom4j.Element)4 Transaction (com.haulmont.cuba.core.Transaction)3 Test (org.testng.annotations.Test)3 Node (com.haulmont.bali.datastruct.Node)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 AppFolder (com.haulmont.cuba.core.entity.AppFolder)2 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)2 ComponentLoaderContext (com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext)2 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)2 Binding (groovy.lang.Binding)2 IOException (java.io.IOException)2 Pair (com.haulmont.bali.datastruct.Pair)1 Tree (com.haulmont.bali.datastruct.Tree)1 MetaModel (com.haulmont.chile.core.model.MetaModel)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 EntityManager (com.haulmont.cuba.core.EntityManager)1 Entity (com.haulmont.cuba.core.entity.Entity)1