use of org.perf4j.StopWatch 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();
}
use of org.perf4j.StopWatch 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();
}
}
use of org.perf4j.StopWatch 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);
}
use of org.perf4j.StopWatch in project bioformats by openmicroscopy.
the class Memoizer method loadMemo.
/**
* Load a memo file if possible, returning a null if not.
*
* Corrupt memo files will be deleted if possible. Kryo
* exceptions should never propagate to the caller. Only
* the regular Bio-Formats exceptions should be thrown.
*/
public IFormatReader loadMemo() throws IOException, FormatException {
if (skipLoad) {
LOGGER.trace("skip load");
return null;
}
if (!memoFile.exists()) {
LOGGER.trace("Memo file doesn't exist: {}", memoFile);
return null;
}
if (!memoFile.canRead()) {
LOGGER.trace("Can't read memo file: {}", memoFile);
return null;
}
long memoLast = memoFile.lastModified();
long realLast = realFile.lastModified();
if (memoLast < realLast) {
LOGGER.debug("memo(lastModified={}) older than real(lastModified={})", memoLast, realLast);
return null;
}
final Deser ser = getDeser();
final StopWatch sw = stopWatch();
IFormatReader copy = null;
ser.loadStart(memoFile);
try {
// VERSION
Integer version = ser.loadVersion();
if (!VERSION.equals(version)) {
LOGGER.info("Old version of memo file: {} not {}", version, VERSION);
return null;
}
// RELEASE VERSION NUMBER
if (versionMismatch()) {
// Logging done in versionMismatch
return null;
}
// CLASS & COPY
try {
copy = ser.loadReader();
} catch (ClassNotFoundException e) {
LOGGER.warn("unknown reader type: {}", e);
return null;
}
boolean equal = false;
try {
equal = FormatTools.equalReaders(reader, copy);
} catch (RuntimeException rt) {
copy.close();
throw rt;
} catch (Error err) {
copy.close();
throw err;
}
if (!equal) {
copy.close();
return null;
}
copy = handleMetadataStore(copy);
if (copy == null) {
LOGGER.debug("metadata store invalidated cache: {}", memoFile);
}
// TODO:
// Check flags
// DataV1 class?
// Handle exceptions on read/write. possibly deleting.
LOGGER.debug("loaded memo file: {} ({} bytes)", memoFile, memoFile.length());
return copy;
} catch (KryoException e) {
LOGGER.warn("deleting invalid memo file: {}", memoFile, e);
LOGGER.debug("Kryo Exception: " + e.getMessage());
deleteQuietly(memoFile);
return null;
} catch (ArrayIndexOutOfBoundsException e) {
LOGGER.warn("deleting invalid memo file: {}", memoFile, e);
LOGGER.debug("ArrayIndexOutOfBoundsException: " + e.getMessage());
deleteQuietly(memoFile);
return null;
} catch (Throwable t) {
// Logging at error since this is unexpected.
LOGGER.error("deleting invalid memo file: {}", memoFile, t);
LOGGER.debug("Other Exception: " + t.getMessage());
deleteQuietly(memoFile);
return null;
} finally {
ser.loadStop();
sw.stop("loci.formats.Memoizer.loadMemo");
}
}
use of org.perf4j.StopWatch 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();
}
Aggregations