Search in sources :

Example 6 with Stopwatch

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

the class MidScaleRepoTest method test010InitResources.

@Test
public void test010InitResources() throws ObjectAlreadyExistsException, SchemaException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("resource.add", "Repository addObject(resource)");
    for (int resourceIndex = 1; resourceIndex <= RESOURCE_COUNT; resourceIndex++) {
        String name = String.format("resource-%03d", resourceIndex);
        ResourceType resourceType = new ResourceType(prismContext).name(PolyStringType.fromOrig(name));
        if (resourceIndex == RESOURCE_COUNT) {
            queryListener.start();
        }
        try (Split ignored = stopwatch.start()) {
            repositoryService.addObject(resourceType.asPrismObject(), null, operationResult);
        }
        resources.put(name, resourceType.getOid());
    }
    queryListener.dumpAndStop();
}
Also used : Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Split(org.javasimon.Split) Test(org.testng.annotations.Test)

Example 7 with Stopwatch

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

the class MidScaleRepoTest method test110GetUser.

@Test
public void test110GetUser() throws SchemaException, ObjectNotFoundException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("user.get1", "Repository getObject() -> user, 1st test");
    for (int i = 1; i <= FIND_COUNT; i++) {
        String randomName = String.format("user-%07d", RND.nextInt(BASE_USER_COUNT) + 1);
        if (i == FIND_COUNT) {
            queryListener.start();
        }
        try (Split ignored = stopwatch.start()) {
            assertThat(repositoryService.getObject(UserType.class, users.get(randomName), null, operationResult)).isNotNull();
        }
    }
    queryListener.dumpAndStop();
}
Also used : Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Split(org.javasimon.Split) Test(org.testng.annotations.Test)

Example 8 with Stopwatch

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

the class PerfTestCodecObject method testCombination.

void testCombination(String format, String ns) throws SchemaException, IOException {
    String inputStream = getCachedStream(Paths.get("common", format, ns, "user-jack." + format));
    Stopwatch parseTimer = stopwatch(monitorName("parse", format, ns), "Parsing user as " + format + " with " + ns);
    Stopwatch serializeTimer = stopwatch(monitorName("serialize", format, ns), "Serializing user as " + format + " with " + ns);
    for (int i = 1; i <= REPETITIONS; i++) {
        PrismObject<Objectable> result;
        try (Split ignored = parseTimer.start()) {
            PrismParser parser = PrismTestUtil.getPrismContext().parserFor(inputStream);
            result = parser.parse();
        }
        assertNotNull(result);
        PrismSerializer<String> serializer = PrismTestUtil.getPrismContext().serializerFor(format);
        String serialized;
        try (Split ignored = serializeTimer.start()) {
            serialized = serializer.serialize(result);
        }
        assertNotNull(serialized);
        assertTrue(!serialized.isEmpty());
    }
}
Also used : Objectable(com.evolveum.midpoint.prism.Objectable) Stopwatch(org.javasimon.Stopwatch) Split(org.javasimon.Split) PrismParser(com.evolveum.midpoint.prism.PrismParser)

Example 9 with Stopwatch

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

the class MidScaleNewRepoTest method test616AddPeakShadowsWithOid.

@Test
public void test616AddPeakShadowsWithOid() throws ObjectAlreadyExistsException, SchemaException {
    OperationResult operationResult = createOperationResult();
    Stopwatch stopwatch = stopwatch("shadow.addPeakWithOid", "Repository addObject(shadow) - 4th batch");
    for (int userIndex = 1; userIndex <= PEAK_USER_COUNT; userIndex++) {
        for (Map.Entry<String, String> resourceEntry : resources.entrySet()) {
            String name = String.format("shadow-peak-oid-%07d-at-%s", userIndex, resourceEntry.getKey());
            ShadowType shadowType = createShadow(name, resourceEntry.getValue()).oid(UUID.randomUUID().toString());
            try (Split ignored = stopwatch.start()) {
                repositoryService.addObject(shadowType.asPrismObject(), null, operationResult);
            }
        }
    }
// no query recorder in this test
}
Also used : Stopwatch(org.javasimon.Stopwatch) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Split(org.javasimon.Split) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 10 with Stopwatch

use of org.javasimon.Stopwatch 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)

Aggregations

Split (org.javasimon.Split)35 Stopwatch (org.javasimon.Stopwatch)35 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 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 URI (java.net.URI)1