Search in sources :

Example 11 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch 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 12 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch 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 13 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch 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 14 with Slf4JStopWatch

use of org.perf4j.slf4j.Slf4JStopWatch 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)

Example 15 with Slf4JStopWatch

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

the class DesktopAbstractTable method packRows.

/**
 * Sets the height of each row into the preferred height of the tallest cell in that row.
 */
public void packRows() {
    if (!contentRepaintEnabled) {
        return;
    }
    impl.setRowHeight(defaultRowHeight);
    for (Column column : columnsOrder) {
        if (column.isEditable()) {
            impl.setRowHeight(defaultEditableRowHeight);
            break;
        }
    }
    if (allColumnsAreInline()) {
        return;
    }
    int preferredRowHeight = -1;
    boolean equalsRowHeight = true;
    StopWatch sw = new Slf4JStopWatch("DAT packRows " + id);
    for (int r = 0; r < impl.getRowCount(); r++) {
        int h = getPreferredRowHeight(r);
        if (preferredRowHeight == -1) {
            preferredRowHeight = h;
        } else if (preferredRowHeight != h) {
            equalsRowHeight = false;
        }
        if (impl.getRowHeight(r) != h) {
            impl.setRowHeight(r, h);
        }
    }
    if (equalsRowHeight && preferredRowHeight > 0) {
        impl.setRowHeight(preferredRowHeight);
    }
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) TableColumn(javax.swing.table.TableColumn) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

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