Search in sources :

Example 11 with Split

use of org.javasimon.Split in project midpoint by Evolveum.

the class AbstractSchemaPerformanceTest method measureSingle.

protected double measureSingle(String label, CheckedProducer<?> producer, long executionTime, Stopwatch watch) throws CommonException {
    long until = System.currentTimeMillis() + executionTime;
    int iteration = 0;
    while (System.currentTimeMillis() < until) {
        Object result = null;
        iteration++;
        try (Split split = watch.start()) {
            result = producer.get();
        }
        if (result == null) {
            // just to make sure the result is used somehow (and not optimized away)
            throw new IllegalStateException("null result from the producer");
        }
    }
    double micros = ((double) executionTime) * 1000 / iteration;
    String message = label + ": " + iteration + " iterations in " + executionTime + " milliseconds (" + micros + " us per iteration)";
    System.out.println(message);
    logger.info(message);
    return micros;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Split(org.javasimon.Split)

Example 12 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class CreateNeedMessageProcessor method authorizeOwnerApplicationForNeed.

private void authorizeOwnerApplicationForNeed(final String ownerApplicationID, Need need) {
    String stopwatchName = getClass().getName() + ".authorizeOwnerApplicationForNeed";
    Stopwatch stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase1");
    Split split = stopwatch.start();
    List<OwnerApplication> ownerApplications = ownerApplicationRepository.findByOwnerApplicationId(ownerApplicationID);
    split.stop();
    stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase2");
    split = stopwatch.start();
    if (ownerApplications.size() > 0) {
        logger.debug("owner application is already known");
        OwnerApplication ownerApplication = ownerApplications.get(0);
        List<OwnerApplication> authorizedApplications = need.getAuthorizedApplications();
        if (authorizedApplications == null) {
            authorizedApplications = new ArrayList<OwnerApplication>(1);
        }
        authorizedApplications.add(ownerApplication);
        need.setAuthorizedApplications(authorizedApplications);
    } else {
        logger.debug("owner application is new - creating");
        List<OwnerApplication> ownerApplicationList = new ArrayList<>(1);
        OwnerApplication ownerApplication = new OwnerApplication();
        ownerApplication.setOwnerApplicationId(ownerApplicationID);
        ownerApplicationList.add(ownerApplication);
        need.setAuthorizedApplications(ownerApplicationList);
        logger.debug("setting OwnerApp ID: " + ownerApplicationList.get(0));
    }
    split.stop();
    stopwatch = SimonManager.getStopwatch(stopwatchName + "_phase3");
    split = stopwatch.start();
    need = needRepository.save(need);
    split.stop();
}
Also used : Stopwatch(org.javasimon.Stopwatch) ArrayList(java.util.ArrayList) Split(org.javasimon.Split)

Example 13 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class MatchingLoadTestMonitorAction method doRun.

@Override
protected void doRun(final Event event, EventListener executingListener) throws Exception {
    Stopwatch stopwatch = SimonManager.getStopwatch("atomHintFullRoundtrip");
    if (event instanceof AtomCreatedEvent) {
        Split split = stopwatch.start();
        atomSplits.put(((AtomCreatedEvent) event).getAtomURI().toString(), split);
        logger.info("RECEIVED EVENT {} for uri {}", event, ((AtomCreatedEvent) event).getAtomURI().toString());
        long startTime = System.currentTimeMillis();
        String atomUri = ((AtomCreatedEvent) event).getAtomURI().toString();
        atomEventStartTime.put(atomUri, startTime);
    } else if (event instanceof AtomHintFromMatcherEvent) {
        String atomUri = ((AtomHintFromMatcherEvent) event).getRecipientAtom().toString();
        logger.info("RECEIVED EVENT {} for uri {}", event, atomUri);
        long hintReceivedTime = System.currentTimeMillis();
        atomSplits.get(atomUri).stop();
        hintEventReceivedTime.computeIfAbsent(atomUri, k -> new LinkedList<>());
        hintEventReceivedTime.get(atomUri).add(hintReceivedTime);
    } else if (event instanceof SocketHintFromMatcherEvent) {
        String atomUri = ((SocketHintFromMatcherEvent) event).getRecipientSocket().toString();
        logger.info("RECEIVED EVENT {} for uri {}", event, atomUri);
        long hintReceivedTime = System.currentTimeMillis();
        atomSplits.get(atomUri).stop();
        hintEventReceivedTime.computeIfAbsent(atomUri, k -> new LinkedList<>());
        hintEventReceivedTime.get(atomUri).add(hintReceivedTime);
    }
    if (startTestTime == -1) {
        startTestTime = System.currentTimeMillis();
    }
    logger.info("Number of Atoms: {}", atomEventStartTime.size());
    logger.info("Number of Hints: {}", getTotalHints());
    logger.info("Number of Atoms with Hints: {}", getAtomsWithHints());
    logger.info("Average Duration: {}", getAverageHintDuration());
    logger.info("Minimum Duration: {}", getMinHintDuration());
    logger.info("Maximum Duration: {}", getMaxHintDuration());
    logger.info("Atoms with Hints per Second: {}", getAtomsWithAtomsPerSecond(startTestTime));
    logger.info("Hints per Second: {}", getHintsPerSecondThroughput(startTestTime));
}
Also used : AtomCreatedEvent(won.bot.framework.eventbot.event.impl.atomlifecycle.AtomCreatedEvent) java.util(java.util) Logger(org.slf4j.Logger) Split(org.javasimon.Split) MethodHandles(java.lang.invoke.MethodHandles) LoggerFactory(org.slf4j.LoggerFactory) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) SocketHintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.SocketHintFromMatcherEvent) Stopwatch(org.javasimon.Stopwatch) SimonManager(org.javasimon.SimonManager) Event(won.bot.framework.eventbot.event.Event) EventListener(won.bot.framework.eventbot.listener.EventListener) AtomHintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.AtomHintFromMatcherEvent) EventListenerContext(won.bot.framework.eventbot.EventListenerContext) SocketHintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.SocketHintFromMatcherEvent) Stopwatch(org.javasimon.Stopwatch) Split(org.javasimon.Split) AtomCreatedEvent(won.bot.framework.eventbot.event.impl.atomlifecycle.AtomCreatedEvent) AtomHintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.AtomHintFromMatcherEvent)

Example 14 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class MonitoringService method stopClock.

public void stopClock(String stopWatchName, String splitName) {
    if (isMonitoringEnabled()) {
        Map<String, Split> splits = stopWatchSplits.get(stopWatchName);
        if (splits == null) {
            logger.warn("No stopwatch '{}' found for monitoring end event", stopWatchName);
            return;
        }
        Split split = splits.get(splitName);
        if (split == null) {
            logger.warn("No split '{}' in stopwatch '{}' found for monitoring end event", splitName, stopWatchName);
            return;
        }
        split.stop();
    // splits.remove(monitoringEvent.getSplitName());
    }
}
Also used : Split(org.javasimon.Split)

Example 15 with Split

use of org.javasimon.Split in project webofneeds by researchstudio-sat.

the class BaseEventBotAction method getActionTask.

@Override
public Runnable getActionTask(final Event event, final EventListener eventListener) {
    return () -> {
        MDC.clear();
        Stopwatch stopwatch = SimonManager.getStopwatch(stopwatchName);
        Split split = stopwatch.start();
        try {
            doRun(event, eventListener);
            split.stop();
        } catch (Exception e) {
            eventListenerContext.getEventBus().publish(new ErrorEvent(e));
            logger.warn("Encountered an Exception:", e);
            split.stop(EXCEPTION_TAG);
        } catch (Throwable t) {
            logger.warn("could not run action {}", stopwatchName, t);
            split.stop(EXCEPTION_TAG);
            throw t;
        }
    };
}
Also used : Stopwatch(org.javasimon.Stopwatch) ErrorEvent(won.bot.framework.eventbot.event.impl.lifecycle.ErrorEvent) Split(org.javasimon.Split)

Aggregations

Split (org.javasimon.Split)38 Stopwatch (org.javasimon.Stopwatch)36 Test (org.testng.annotations.Test)28 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)11 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)8 AbstractGuiIntegrationTest (com.evolveum.midpoint.web.AbstractGuiIntegrationTest)5 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)5 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 QUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser)4 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 SkipException (org.testng.SkipException)3 Objectable (com.evolveum.midpoint.prism.Objectable)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismParser (com.evolveum.midpoint.prism.PrismParser)1 QResource (com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1