本文整理汇总了Java中org.perf4j.slf4j.Slf4JStopWatch类的典型用法代码示例。如果您正苦于以下问题:Java Slf4JStopWatch类的具体用法?Java Slf4JStopWatch怎么用?Java Slf4JStopWatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Slf4JStopWatch类属于org.perf4j.slf4j包,在下文中一共展示了Slf4JStopWatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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));
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
}