/** * Gets a copy of the metrics that is immutable. Once this clone is made, the {@link MutableMetrics} can no * longer be modified themselves. This prevents custom steps that implement {@link Profiling} from adding to * the metrics after the traversal is complete. */ public synchronized ImmutableMetrics getImmutableClone() { finalized = true; final ImmutableMetrics clone = new ImmutableMetrics(); copyMembers(clone); this.nested.values().forEach(nested -> clone.nested.put(nested.id, ((MutableMetrics) nested).getImmutableClone())); return clone; }
@Override public OResult transform(DefaultTraversalMetrics value) { OResultInternal result = new OResultInternal(); result.setProperty("time (ms)", value.getDuration(TimeUnit.MILLISECONDS)); List<OResultInternal> steps = value.getMetrics().stream().map((m) -> { OResultInternal internal = new OResultInternal(); internal.setProperty("id", m.getId()); internal.setProperty("time (ms)", m.getDuration(TimeUnit.MILLISECONDS)); internal.setProperty("name", m.getName()); return internal; }).collect(Collectors.toList()); result.setProperty("steps", steps); return result; } }
public void stop(FillChildren fillChildren) { controllerMetrics.stop(); if (metrics.isPresent()) { fillChildren.fillChildren(controllerMetrics.getNested().stream().map(m -> ((MutableMetrics) m)).collect(Collectors.toList())); controllerMetrics.setCount(TraversalMetrics.ELEMENT_COUNT_ID, controllerMetrics.getNested().stream() .mapToLong(n -> n.getCount(TraversalMetrics.ELEMENT_COUNT_ID)).sum()); } } }
/** * Gets a copy of the metrics that is immutable. Once this clone is made, the {@link MutableMetrics} can no * longer be modified themselves. This prevents custom steps that implement {@link Profiling} from adding to * the metrics after the traversal is complete. */ public synchronized ImmutableMetrics getImmutableClone() { finalized = true; final ImmutableMetrics clone = new ImmutableMetrics(); copyMembers(clone); this.nested.values().forEach(nested -> clone.nested.put(nested.id, ((MutableMetrics) nested).getImmutableClone())); return clone; }