use of org.hisp.dhis.util.Timer in project dhis2-core by dhis2.
the class DefaultEventAnalyticsService method addEventData.
/**
* Adds event data to the given grid. Returns the number of events matching
* the given event query.
*
* @param grid the {@link Grid}.
* @param params the {@link EventQueryParams}.
* @return the count of events.
*/
@Override
protected long addEventData(Grid grid, EventQueryParams params) {
Timer timer = new Timer().start().disablePrint();
params = queryPlanner.planEventQuery(params);
timer.getSplitTime("Planned event query, got partitions: " + params.getPartitions());
long count = 0;
if (params.getPartitions().hasAny() || params.isSkipPartitioning()) {
if (params.isPaging()) {
count += eventAnalyticsManager.getEventCount(params);
}
eventAnalyticsManager.getEvents(params, grid, queryValidator.getMaxLimit());
timer.getTime("Got events " + grid.getHeight());
}
return count;
}
use of org.hisp.dhis.util.Timer in project dhis2-core by dhis2.
the class AuditRepositoryTest method testAuditInsertBatch200k.
@Test
@Disabled
void testAuditInsertBatch200k() {
List<Audit> audits = new ArrayList<>();
IntStream.rangeClosed(1, 200_000).forEach(n -> {
String uid = CodeGenerator.generateUid();
String code = CodeGenerator.generateUid();
Audit audit = Audit.builder().auditType(AuditType.CREATE).auditScope(AuditScope.AGGREGATE).createdAt(LocalDateTime.of(2000, 1, 1, 0, 0)).createdBy("test-user").klass(DataElement.class.getName()).uid(uid).code(code).data("{}").build();
audits.add(audit);
});
Timer timer = new Timer().start();
auditRepository.save(audits);
System.err.println("Batch Insert: " + timer.getTimeInS() + "s");
assertEquals(200_000, auditRepository.count(AuditQuery.builder().build()));
}
Aggregations