Search in sources :

Example 11 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class WindowManager method initWrapperFrame.

protected void initWrapperFrame(Window wrappingWindow, ComponentLoaderContext context, Element element, Map<String, Object> params) {
    if (wrappingWindow instanceof AbstractWindow) {
        Element companionsElem = element.element("companions");
        if (companionsElem != null) {
            StopWatch companionStopWatch = new Slf4JStopWatch(wrappingWindow.getId() + "#" + LifeCycle.COMPANION, LoggerFactory.getLogger(UIPerformanceLogger.class));
            initCompanion(companionsElem, (AbstractWindow) wrappingWindow);
            companionStopWatch.stop();
        }
    }
    StopWatch injectStopWatch = new Slf4JStopWatch(wrappingWindow.getId() + "#" + LifeCycle.INJECTION, LoggerFactory.getLogger(UIPerformanceLogger.class));
    ControllerDependencyInjector dependencyInjector = AppBeans.getPrototype(ControllerDependencyInjector.NAME, wrappingWindow, params);
    dependencyInjector.inject();
    injectStopWatch.stop();
    context.executeInjectTasks();
    context.executePostWrapTasks();
    init(wrappingWindow, params);
    context.executeInitTasks();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Element(org.dom4j.Element) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 12 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class AbstractViewRepository method replaceOverridden.

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();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 13 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class AbstractViewRepository method init.

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();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Element(org.dom4j.Element) StrTokenizer(org.apache.commons.lang.text.StrTokenizer) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 14 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class JavaClassLoader method loadClass.

@Override
public Class loadClass(final String fullClassName, boolean resolve) throws ClassNotFoundException {
    String containerClassName = StringUtils.substringBefore(fullClassName, "$");
    StopWatch loadingWatch = new Slf4JStopWatch("LoadClass");
    try {
        lock(containerClassName);
        Class clazz;
        if (!sourceProvider.getSourceFile(containerClassName).exists()) {
            clazz = super.loadClass(fullClassName, resolve);
            return clazz;
        }
        CompilationScope compilationScope = new CompilationScope(this, containerClassName);
        if (!compilationScope.compilationNeeded()) {
            TimestampClass timestampClass = getTimestampClass(fullClassName);
            if (timestampClass == null) {
                throw new ClassNotFoundException(fullClassName);
            }
            return timestampClass.clazz;
        }
        String src;
        try {
            src = sourceProvider.getSourceString(containerClassName);
        } catch (IOException e) {
            throw new ClassNotFoundException("Could not load java sources for class " + containerClassName);
        }
        try {
            log.debug("Compiling " + containerClassName);
            final DiagnosticCollector<JavaFileObject> errs = new DiagnosticCollector<>();
            SourcesAndDependencies sourcesAndDependencies = new SourcesAndDependencies(rootDir, this);
            sourcesAndDependencies.putSource(containerClassName, src);
            sourcesAndDependencies.collectDependencies(containerClassName);
            Map<String, CharSequence> sourcesForCompilation = sourcesAndDependencies.collectSourcesForCompilation(containerClassName);
            @SuppressWarnings("unchecked") Map<String, Class> compiledClasses = createCompiler().compile(sourcesForCompilation, errs);
            Map<String, TimestampClass> compiledTimestampClasses = wrapCompiledClasses(compiledClasses);
            compiled.putAll(compiledTimestampClasses);
            linkDependencies(compiledTimestampClasses, sourcesAndDependencies.dependencies);
            clazz = compiledClasses.get(fullClassName);
            springBeanLoader.updateContext(compiledClasses.values());
            return clazz;
        } catch (Exception e) {
            proxyClassLoader.restoreRemoved();
            throw new RuntimeException(e);
        } finally {
            proxyClassLoader.cleanupRemoved();
        }
    } finally {
        unlock(containerClassName);
        loadingWatch.stop();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) IOException(java.io.IOException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) JavaFileObject(javax.tools.JavaFileObject) DiagnosticCollector(javax.tools.DiagnosticCollector)

Example 15 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class DesktopTableCellEditor method getCellComponent.

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;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Table(com.haulmont.cuba.gui.components.Table) BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Aggregations

StopWatch (org.perf4j.StopWatch)41 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)41 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 KryoException (com.esotericsoftware.kryo.KryoException)1 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