and: 'a list of device nodes to add'
def jsonData = generateOpenRoadData(totalNodes)
when: 'device nodes are added'
- stopWatch.start()
+ resourceMeter.start()
cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', jsonData, OffsetDateTime.now())
- stopWatch.stop()
- def durationInMillis = stopWatch.getTotalTimeMillis()
- then: 'the operation takes less than #expectedDuration'
- recordAndAssertPerformance("Writing ${totalNodes} devices", expectedDuration, durationInMillis)
+ resourceMeter.stop()
+ def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
+ then: 'the operation takes less than #expectedDuration and memory used is within limit'
+ recordAndAssertResourceUsage("Writing ${totalNodes} devices", expectedDurationInSeconds, durationInSeconds, 400, resourceMeter.getTotalMemoryUsageInMB())
cleanup:
cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now())
cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor')
where:
- totalNodes || expectedDuration
- 50 || 2_500
- 100 || 4_000
- 200 || 8_000
- 400 || 16_000
-// 800 || 32_000
-// 1600 || 64_000
-// 3200 || 128_000
+ totalNodes || expectedDurationInSeconds
+ 50 || 3
+ 100 || 5
+ 200 || 10
+ 400 || 20
+// 800 || 40
+// 1600 || 80
+// 3200 || 160
}
def 'Writing bookstore data has exponential time.'() {
and: 'a list of books to add'
def booksData = '{"books":[' + (1..totalBooks).collect {'{ "title": "' + it + '" }' }.join(',') + ']}'
when: 'books are added'
- stopWatch.start()
+ resourceMeter.start()
cpsDataService.saveData(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', '/bookstore/categories[@code=1]', booksData, OffsetDateTime.now())
- stopWatch.stop()
- def durationInMillis = stopWatch.getTotalTimeMillis()
- then: 'the operation takes less than #expectedDuration'
- recordAndAssertPerformance("Writing ${totalBooks} books", expectedDuration, durationInMillis)
+ resourceMeter.stop()
+ def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
+ then: 'the operation takes less than #expectedDuration and memory used is within limit'
+ recordAndAssertResourceUsage("Writing ${totalBooks} books", expectedDuration, durationInSeconds, 400, resourceMeter.getTotalMemoryUsageInMB())
cleanup:
cpsDataService.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor', OffsetDateTime.now())
cpsAdminService.deleteAnchor(CPS_PERFORMANCE_TEST_DATASPACE, 'writeAnchor')
where:
totalBooks || expectedDuration
- 400 || 200
- 800 || 500
- 1600 || 1_000
- 3200 || 2_500
- 6400 || 10_000
-// 12800 || 30_000
-// 25600 || 120_000
-// 51200 || 600_000
+ 400 || 0.2
+ 800 || 0.5
+ 1600 || 1
+ 3200 || 3
+ 6400 || 10
+// 12800 || 30
+// 25600 || 120
+// 51200 || 600
}
}