OCTimer - Global
-
- UpdatedAug 3, 2023
- 4 minutes to read
- Vancouver
- API reference
The OCTimer API provides the ability to track the length of time it takes for a function to complete.
The OCTimer API requires the On-Call Scheduling (com.snc.on_call_rotation) plugin to be activated. For more information, refer to the topic Activate On-Call Scheduling.
OCTimer - log (String name, String entry)
Logs the entry based on the function name.
Name | Type | Description |
---|---|---|
name | String | Function name. |
entry | String | Text that will be part of the output in the log. |
Type | Description |
---|---|
void |
OCTimer - millisToTime (Integer millis)
Takes a millisecond value and returns a formatted duration.
Name | Type | Description |
---|---|---|
millis | Integer | Duration in miliseconds. |
Type | Description |
---|---|
String | A formatted duration. |
OCTimer - result ()
Calculates the time taken for each function registered.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Time taken for each function registered. |
Example
The following code example benchmarks the time taken by a REST API to fetch IP addresses from devices in Network Gear and then inserts them into IP Address table. API calls may require some time to process, so it is advisable to benchmark execution time before executing them in production.
Output:
OCTimer - start (String name)
Initializes a timer based on the name provided.
Name | Type | Description |
---|---|---|
name | String | Function name. |
Type | Description |
---|---|
void |
Example
The following code example benchmarks the time taken by a REST API to fetch IP addresses from devices in Network Gear and then inserts them into IP Address table. API calls may require some time to process, so it is advisable to benchmark execution time before executing them in production.
Output:
OCTimer - stop (String name)
Registers the end of the timer for the provided name.
Name | Type | Description |
---|---|---|
name | String | Function name. |
Type | Description |
---|---|
void |
Example
The following code example benchmarks the time taken by a REST API to fetch IP addresses from devices in Network Gear and then inserts them into IP Address table. API calls may require some time to process, so it is advisable to benchmark execution time before executing them in production.
Output: