X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ri%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fspi%2Fimpl%2FCpsPersistencePerfSpecBase.groovy;h=b67a5cc68661d995d0638403d2139328b54473ca;hb=0fa2fabeec18763bab060d85f5123bceff8ee34c;hp=3bbae2d08c04c8548d4ce5e7e638fe8149c3f9ba;hpb=3d878b0674cd61e64501dfe6564b8921e76056bb;p=cps.git diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy index 3bbae2d08..b67a5cc68 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistencePerfSpecBase.groovy @@ -22,6 +22,7 @@ package org.onap.cps.spi.impl import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.DataNodeBuilder +import org.springframework.util.StopWatch class CpsPersistencePerfSpecBase extends CpsPersistenceSpecBase { @@ -32,6 +33,18 @@ class CpsPersistencePerfSpecBase extends CpsPersistenceSpecBase { static def xpathsToAllGrandChildren = [] + static def PERFORMANCE_RECORD = [] + + def stopWatch = new StopWatch() + + def cleanupSpec() { + println('#############################################################################') + println('## P E R F O R M A N C E T E S T R E S U L T S ##') + println('#############################################################################') + PERFORMANCE_RECORD.sort().each { println(it) } + PERFORMANCE_RECORD.clear() + } + def createLineage(cpsDataPersistenceService, numberOfChildren, numberOfGrandChildren, createLists) { xpathsToAllGrandChildren = [] (1..numberOfChildren).each { @@ -71,4 +84,16 @@ class CpsPersistencePerfSpecBase extends CpsPersistenceSpecBase { } return nodeCount } + + def recordAndAssertPerformance(String shortTitle, thresholdInMs, recordedTimeInMs) { + def pass = recordedTimeInMs <= thresholdInMs + if (shortTitle.length()>40) { + shortTitle = shortTitle.substring(0,40) + } + def record = String.format('%2d.%-40s limit%,7d took %,7d ms ', PERFORMANCE_RECORD.size()+1, shortTitle, thresholdInMs, recordedTimeInMs) + record += pass?'PASS':'FAIL' + PERFORMANCE_RECORD.add(record) + assert recordedTimeInMs <= thresholdInMs + return true + } }