@Override public MutableMetrics clone() { final MutableMetrics clone = new MutableMetrics(); copyMembers(clone); this.nested.values().forEach(nested -> clone.nested.put(nested.id, ((MutableMetrics) nested).clone())); return clone; }
private void addTopLevelMetrics(final Traversal.Admin traversal, final boolean onGraphComputer) { this.totalStepDuration = 0; final List<ProfileStep> profileSteps = TraversalHelper.getStepsOfClass(ProfileStep.class, traversal); final List<Pair<Integer, MutableMetrics>> tempMetrics = new ArrayList<>(profileSteps.size()); for (int ii = 0; ii < profileSteps.size(); ii++) { // The index is necessary to ensure that step order is preserved after a merge. final ProfileStep step = profileSteps.get(ii); final MutableMetrics stepMetrics = onGraphComputer ? traversal.getSideEffects().get(step.getId()) : step.getMetrics(); this.totalStepDuration += stepMetrics.getDuration(MutableMetrics.SOURCE_UNIT); tempMetrics.add(Pair.with(ii, stepMetrics.clone())); } tempMetrics.forEach(m -> { final double dur = m.getValue1().getDuration(TimeUnit.NANOSECONDS) * 100.d / this.totalStepDuration; m.getValue1().setAnnotation(PERCENT_DURATION_KEY, dur); }); tempMetrics.forEach(p -> { this.stepIndexedMetrics.put(p.getValue1().getId(), p.getValue1().getImmutableClone()); this.positionIndexedMetrics.put(p.getValue0(), p.getValue1().getImmutableClone()); }); }
@Override public MutableMetrics clone() { final MutableMetrics clone = new MutableMetrics(); copyMembers(clone); this.nested.values().forEach(nested -> clone.nested.put(nested.id, ((MutableMetrics) nested).clone())); return clone; }
private void addTopLevelMetrics(final Traversal.Admin traversal, final boolean onGraphComputer) { this.totalStepDuration = 0; final List<ProfileStep> profileSteps = TraversalHelper.getStepsOfClass(ProfileStep.class, traversal); final List<Pair<Integer, MutableMetrics>> tempMetrics = new ArrayList<>(profileSteps.size()); for (int ii = 0; ii < profileSteps.size(); ii++) { // The index is necessary to ensure that step order is preserved after a merge. final ProfileStep step = profileSteps.get(ii); final MutableMetrics stepMetrics = onGraphComputer ? traversal.getSideEffects().get(step.getId()) : step.getMetrics(); this.totalStepDuration += stepMetrics.getDuration(MutableMetrics.SOURCE_UNIT); tempMetrics.add(Pair.with(ii, stepMetrics.clone())); } tempMetrics.forEach(m -> { final double dur = m.getValue1().getDuration(TimeUnit.NANOSECONDS) * 100.d / this.totalStepDuration; m.getValue1().setAnnotation(PERCENT_DURATION_KEY, dur); }); tempMetrics.forEach(p -> { this.stepIndexedMetrics.put(p.getValue1().getId(), p.getValue1().getImmutableClone()); this.positionIndexedMetrics.put(p.getValue0(), p.getValue1().getImmutableClone()); }); }