@Test public void problemContextMustBeGlobalContext() { Timestamp currentTime = new Timestamp(System.currentTimeMillis()); List<InvocationSequenceData> rawInvocations = new ArrayList<InvocationSequenceData>(); TimerData timerData = new TimerData(currentTime, 10L, 20L, 30L); timerData.calculateExclusiveMin(RANDOM.nextDouble()); timerData.setExclusiveDuration(RANDOM.nextDouble()); when(globalContext.getTimerData()).thenReturn(timerData); rawInvocations.add(globalContext); when(timeWastingOperation.getRawInvocationsSequenceElements()).thenReturn(rawInvocations); CauseCluster problemContext = problemContextRule.action(); assertThat("The returned problemContext must be the most significant cluster context", problemContext.getCommonContext(), is(globalContext)); }
@Test public void getExclusiveDurationMustReturnTheExclusiveDurationOfTheTimerDataWhenItIsARegularTimerData() { InvocationSequenceData invocationData = new InvocationSequenceData(); TimerData timerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerData.calculateExclusiveMin(300d); timerData.setExclusiveDuration(300d); invocationData.setTimerData(timerData); double exclusiveDuration = DiagnosisHelper.getExclusiveDuration(invocationData); assertThat("Exclusive duration must be 300.", exclusiveDuration, is(timerData.getExclusiveDuration())); }
@Test public void timerDataMustReturnANotEmptyListOfAggregatedDiagnosisDataWhenTheDurationIsTooLong() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstSeqTimerData); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); nestedSequences.add(firstChildSequence); nestedSequences.add(secondChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("Action method must return a list of AggregatedDiagnosisData not empty", timeWastingOperationsResults, not(hasSize(0))); }
@Test public void timerDataMustReturnANotNullListOfAggregatedDiagnosisData() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstSeqTimerData); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); nestedSequences.add(firstChildSequence); nestedSequences.add(secondChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("The returned list of AggregatedDiagnosisData must not be null", timeWastingOperationsResults, notNullValue()); }
@Test public void timerDataMustReturnAListOfAggregatedDiagnosisDataWithOneElement() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstSeqTimerData); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); nestedSequences.add(firstChildSequence); nestedSequences.add(secondChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("Action method must return a list with one AggregatedDiagnosisData", timeWastingOperationsResults, hasSize(1)); }
@Test public void timerDataMustReturnAValidListOfAggregatedDiagnosisData() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstSeqTimerData); nestedSequences.add(firstChildSequence); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); nestedSequences.add(secondChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperations = timeWastingOperationsRule.action(); assertThat("Action method must return a list of AggregatedDiagnosisData not empty", timeWastingOperations, not(hasSize(0))); for (AggregatedDiagnosisData AggregatedDiagnosisInvocationData : timeWastingOperations) { isAValidAggregatedDiagnosisData(AggregatedDiagnosisInvocationData); } }
@Test public void rootCauseMustBeNotNullWhenMethodIdentIsEqualAndTheInvocationHasTimerData() { double highDuration = RANDOM.nextDouble() + 1000; List<InvocationSequenceData> nestedSequences = new ArrayList<InvocationSequenceData>(); InvocationSequenceData firstChildSequenceData = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData timerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerData.calculateExclusiveMin(RANDOM.nextDouble()); timerData.setExclusiveDuration(RANDOM.nextDouble()); firstChildSequenceData.setTimerData(timerData); InvocationSequenceData secondChildSequenceData = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); timerData.calculateExclusiveMin(RANDOM.nextDouble()); timerData.setExclusiveDuration(RANDOM.nextDouble()); secondChildSequenceData.setTimerData(timerData); nestedSequences.add(firstChildSequenceData); nestedSequences.add(secondChildSequenceData); when(problemContext.getCommonContext()).thenReturn(commonContext); when(commonContext.getMethodIdent()).thenReturn(1L); when(commonContext.getDuration()).thenReturn(highDuration); when(problemContext.getCauseInvocations()).thenReturn(nestedSequences); AggregatedDiagnosisData rootCause = problemCauseRule.action(); assertThat("The returned root cause rule must not be null", rootCause, notNullValue()); }
@Test public void timerDataMustReturnAListOfAggregatedDiagnosisDataWithTwoElementsWhenItsDurationIsHigherThanTheBaseline() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(1008d); firstSeqTimerData.setExclusiveDuration(1008d); firstChildSequence.setTimerData(firstSeqTimerData); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); InvocationSequenceData thirdChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 3L); TimerData thirdTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); thirdTimerData.calculateExclusiveMin(2000d); thirdTimerData.setExclusiveDuration(2000d); thirdChildSequence.setTimerData(thirdTimerData); nestedSequences.add(firstChildSequence); nestedSequences.add(secondChildSequence); nestedSequences.add(thirdChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("Action method must return a list with two AggregatedDiagnosisData", timeWastingOperationsResults, hasSize(2)); assertThat("Identifier is not the expected one, the first result must have 1 as method identifier", timeWastingOperationsResults.get(0).getMethodIdent(), is(3L)); assertThat("Identifier is not the expected one, the first result must have 3 as method identifier", timeWastingOperationsResults.get(1).getMethodIdent(), is(1L)); }
@Test public void timerDataMustReturnAListOfAggregatedDiagnosisDataWithTwoElements() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstSeqTimerData); InvocationSequenceData secondChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); InvocationSequenceData thirdChildSequence = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 3L); TimerData thirdTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); thirdTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); thirdChildSequence.setTimerData(thirdTimerData); nestedSequences.add(firstChildSequence); nestedSequences.add(secondChildSequence); nestedSequences.add(thirdChildSequence); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("Action method must return a list with two AggregatedDiagnosisData", timeWastingOperationsResults, hasSize(2)); }
@Test public void rootCauseMustHaveTwoElementsInRawInvocationSequence() { List<InvocationSequenceData> nestedSequences = new ArrayList<InvocationSequenceData>(); InvocationSequenceData firstChildSequenceData = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData timerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); TimerData firstTimerData = timerData; firstTimerData.setExclusiveDuration(2000); firstTimerData.setDuration(2000); firstChildSequenceData.setTimerData(firstTimerData); InvocationSequenceData secondChildSequenceData = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData secondTimerData = timerData; secondTimerData.setExclusiveDuration(100); secondTimerData.setDuration(100); secondChildSequenceData.setTimerData(secondTimerData); nestedSequences.add(firstChildSequenceData); nestedSequences.add(secondChildSequenceData); when(problemContext.getCommonContext()).thenReturn(commonContext); when(commonContext.getMethodIdent()).thenReturn(METHOD_IDENT_EQUAL); when(commonContext.getDuration()).thenReturn(3100.0); when(problemContext.getCauseInvocations()).thenReturn(nestedSequences); AggregatedDiagnosisData rootCause = problemCauseRule.action(); assertThat("Raw invocation sequence must have two elements", rootCause.getRawInvocationsSequenceElements(), hasSize(2)); }
@Test public void timerDataMustReturnTheExpectedAggregatedDiagnosisData() { long platformIdent = 108; long sensorTypeIdent = 1; double highDuration = 2000; Timestamp defDate = new Timestamp(new Date().getTime()); List<InvocationSequenceData> nestedSequences = new ArrayList<>(); InvocationSequenceData firstMethod = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 1L); TimerData firstSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstSeqTimerData.calculateExclusiveMin(200d); firstSeqTimerData.setExclusiveDuration(200d); firstMethod.setTimerData(firstSeqTimerData); InvocationSequenceData secondMethod = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 2L); InvocationSequenceData thirdMethod = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, 3L); TimerData thirdSeqTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); thirdSeqTimerData.calculateExclusiveMin(200d); thirdSeqTimerData.setExclusiveDuration(200d); thirdMethod.setTimerData(thirdSeqTimerData); nestedSequences.add(firstMethod); nestedSequences.add(secondMethod); nestedSequences.add(thirdMethod); when(globalContext.getDuration()).thenReturn(highDuration); when(globalContext.getNestedSequences()).thenReturn(nestedSequences); List<AggregatedDiagnosisData> timeWastingOperationsResults = timeWastingOperationsRule.action(); assertThat("Identifier is not the expected one, the first result must have 1 as method identifier", timeWastingOperationsResults.get(0).getMethodIdent(), is(1L)); assertThat("Identifier is not the expected one, the first result must have 3 as method identifier", timeWastingOperationsResults.get(1).getMethodIdent(), is(3L)); }
TimerData firstChildTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); firstChildTimerData.calculateExclusiveMin(200d); firstChildTimerData.setExclusiveDuration(200d); firstChildSequence.setTimerData(firstChildTimerData); TimerData higherDurationChildTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); higherDurationChildTimerData.calculateExclusiveMin(4000d); higherDurationChildTimerData.setExclusiveDuration(4000d); higherDurationChild.setTimerData(higherDurationChildTimerData); TimerData secondChildSequenceTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); secondChildSequenceTimerData.calculateExclusiveMin(500d); secondChildSequenceTimerData.setExclusiveDuration(500d); secondChildSequence.setTimerData(secondChildSequenceTimerData);
TimerData timerData = new TimerData(currentTime, 10L, 20L, 30L); timerData.calculateExclusiveMin(RANDOM.nextDouble()); timerData.setExclusiveDuration(2000d); globalContext.setTimerData(timerData); InvocationSequenceData significantContext = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, methodIdent); timerData.setExclusiveDuration(8000d); significantContext.setTimerData(timerData); significantContext.setParentSequence(globalContext); InvocationSequenceData significantContextChildWithParent = new InvocationSequenceData(defDate, platformIdent, sensorTypeIdent, methodIdent); timerData.setExclusiveDuration(4000d); significantContextChildWithParent.setTimerData(timerData); significantContextChildWithParent.setParentSequence(significantContext); TimerData timeWastingOperationTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timeWastingOperationTimerData.calculateExclusiveMin(1); timeWastingOperationTimerData.setExclusiveDuration(2000); timeWastingOperationTimerData.setDuration(2000); AggregatedDiagnosisTimerData aggregatedDiagnosisTimerData = new AggregatedDiagnosisTimerData(timeWastingOperationTimerData);
verify(timerData, times(0)).setDuration(anyDouble()); verify(timerData, times(0)).setExclusiveCount(anyLong()); verify(timerData, times(0)).setExclusiveDuration(anyDouble()); verify(timerData, times(0)).calculateExclusiveMax(anyDouble()); verify(timerData, times(0)).calculateExclusiveMin(anyDouble());
TimerData timerDataSeachDB = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataSeachDB.setDuration(2000); timerDataSeachDB.setExclusiveDuration(2000d); parentSequence.setTimerData(timerDataSeachDB); parentSequence.setDuration(2000d); TimerData timerDataFirstSequence = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstSequence.setDuration(100d); timerDataFirstSequence.setExclusiveDuration(100d); timerDataFirstSequence.calculateExclusiveMin(1d); firstSequence.setTimerData(timerDataFirstSequence); TimerData timerDataSignificantCluster = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataSignificantCluster.setDuration(1700d); timerDataSignificantCluster.setExclusiveDuration(1700d); timerDataSignificantCluster.calculateExclusiveMin(1d); significantCluster.setTimerData(timerDataSignificantCluster); TimerData timerDataSecondSequence = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataSecondSequence.setDuration(200d); timerDataSecondSequence.setExclusiveDuration(200d); timerDataSecondSequence.calculateExclusiveMin(1d); secondSequence.setTimerData(timerDataSecondSequence); TimerData timeWastingOperationTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timeWastingOperationTimerData.calculateExclusiveMin(1); timeWastingOperationTimerData.setExclusiveDuration(2000); timeWastingOperationTimerData.setDuration(2200); AggregatedDiagnosisTimerData aggregatedDiagnosisTimerData = new AggregatedDiagnosisTimerData(timeWastingOperationTimerData);
TimerData timerDataGlobalContext = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataGlobalContext.setDuration(Short.MAX_VALUE); timerDataGlobalContext.setExclusiveDuration(Short.MAX_VALUE); rootInvocation.setTimerData(timerDataGlobalContext); rootInvocation.setDuration(Short.MAX_VALUE); TimerData timerDataFirstSequence = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstSequence.setDuration(Short.MAX_VALUE); timerDataFirstSequence.setExclusiveDuration(Short.MAX_VALUE); firstSequence.setTimerData(timerDataFirstSequence); firstSequence.setDuration(Short.MAX_VALUE); TimerData timerDataExpectedProblemContext = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataExpectedProblemContext.setDuration(Short.MAX_VALUE); timerDataExpectedProblemContext.setExclusiveDuration(Short.MAX_VALUE); expectedProblemContext.setTimerData(timerDataExpectedProblemContext); expectedProblemContext.setDuration(Short.MAX_VALUE); TimerData timerDataFirstChildSequence = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstChildSequence.setDuration(1d); timerDataFirstChildSequence.setExclusiveDuration(1d); invocation.setTimerData(timerDataFirstChildSequence); invocation.setDuration(1d); TimerData timeWastingOperationTimerData = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timeWastingOperationTimerData.calculateExclusiveMin(1); timeWastingOperationTimerData.setExclusiveDuration(Short.MAX_VALUE); timeWastingOperationTimerData.setDuration(Short.MAX_VALUE); AggregatedDiagnosisTimerData aggregatedDiagnosisTimerData = new AggregatedDiagnosisTimerData(timeWastingOperationTimerData);
InvocationSequenceData currentProblemContext = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, methodIdentDiff); TimerData timerDataCurrentProblemContext = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataCurrentProblemContext.setExclusiveDuration(2500d); timerDataCurrentProblemContext.calculateExclusiveMin(1d); currentProblemContext.setTimerData(timerDataCurrentProblemContext); InvocationSequenceData firstMethod = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData timerDataFirstMethod = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstMethod.setExclusiveDuration(1200d); timerDataFirstMethod.calculateExclusiveMin(1d); firstMethod.setTimerData(timerDataFirstMethod); InvocationSequenceData secondMethod = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData timerDataSecondMethod = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataSecondMethod.setExclusiveDuration(800d); timerDataSecondMethod.calculateExclusiveMin(1d); secondMethod.setTimerData(timerDataSecondMethod); InvocationSequenceData thirdMethod = new InvocationSequenceData(DEF_DATE, PLATFORM_IDENT, SENSOR_TYPE_IDENT, METHOD_IDENT_EQUAL); TimerData timerDataThirdMethod = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataThirdMethod.setExclusiveDuration(500d); timerDataThirdMethod.calculateExclusiveMin(1d); thirdMethod.setTimerData(timerDataThirdMethod);
TimerData timerDataGlobalContext = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataGlobalContext.setDuration(5200d); timerDataGlobalContext.setExclusiveDuration(5200d); rootInvocation.setTimerData(timerDataGlobalContext); rootInvocation.setDuration(5200d); TimerData timerDataFirstSequence = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstSequence.setDuration(5200d); timerDataFirstSequence.setExclusiveDuration(5200d); firstSequence.setTimerData(timerDataFirstSequence); firstSequence.setDuration(5200d); TimerData timerDataExpectedProblemContext = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataExpectedProblemContext.setDuration(5000d); timerDataExpectedProblemContext.setExclusiveDuration(5000d); expectedProblemContext.setTimerData(timerDataExpectedProblemContext); expectedProblemContext.setDuration(5000d); TimerData timerDataFirstChildSeq = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataFirstChildSeq.setDuration(2400d); timerDataFirstChildSeq.setExclusiveDuration(2400d); timerDataFirstChildSeq.calculateExclusiveMin(1d); firstChildSeq.setTimerData(timerDataFirstChildSeq); TimerData timerDataSecondChildSeq = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); timerDataSecondChildSeq.setDuration(1400d); timerDataSecondChildSeq.setExclusiveDuration(1400d); timerDataSecondChildSeq.calculateExclusiveMin(1d); secondChildSeq.setTimerData(timerDataSecondChildSeq);
/** * Process timer data if one exists in the invData object and passes it to the chained * processors. * * @param entityManager * {@link EntityManager} needed for DB persistence. * @param invData * Invocation data to be processed. * @param topInvocationParent * Top invocation object. * @param exclusiveDurationDelta * Duration to subtract from timer duration to get the exclusive duration. */ private void processTimerData(EntityManager entityManager, InvocationSequenceData invData, InvocationSequenceData topInvocationParent, double exclusiveDurationDelta) { TimerData timerData = invData.getTimerData(); if (null != timerData) { double exclusiveTime = invData.getTimerData().getDuration() - exclusiveDurationDelta; timerData.setExclusiveCount(1L); timerData.setExclusiveDuration(exclusiveTime); timerData.calculateExclusiveMax(exclusiveTime); timerData.calculateExclusiveMin(exclusiveTime); timerData.addInvocationParentId(topInvocationParent.getId()); passToChainedProcessors(invData.getTimerData(), entityManager); } }
timerData.setDuration(DURATION); timerData.setCpuDuration(DURATION); timerData.setExclusiveDuration(DURATION); timerData.calculateMin(MIN); timerData.calculateCpuMin(MIN);