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();
}
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();
}
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());
}
}
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
}
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();
}
Aggregations