testRTC offers timing mechanisms, enabling you to time certain activities within your web service.
With these, you can set expectations based on timing, or collect timing related custom metrics.
rtcStartTimer()
testRTC timer functions can be used to measure the time interval between two points (A and B) in the test script. In order to measure the time interval, use function .rtcStartTimer() in location A in the script and function .rtcGetTimer() in location B in the script.
Arguments
Name | Type | Description |
---|---|---|
key | string | The name of the timer to start |
rtcGetTimer()
Returns the time elapsed from timer start time.
Arguments
Name | Type | Description |
---|---|---|
key | string | The name of the timer to get |
callback | function | Callback function to be called with the time elapsed since the timer started |
Code example
client
.rtcStartTimer('myTimer')
.rtcGetTimer('myTimer', function(timer) {
client.rtcInfo('Time: %d', timer)
})
.rtcSetMetricFromTimer('tmetric', 'myTimer');
Code language: JavaScript (javascript)
Remarks:
- Check out the custom metrics commands to see how you can set a metric’s value from a timer