Created
March 31, 2016 20:17
-
-
Save hassy/f6f7604592f393bbf710ad2e071d6242 to your computer and use it in GitHub Desktop.
Example of using processors in Artillery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config: | |
target: "http://localhost:8080" | |
phases: | |
- duration: 60 | |
arrivalRate: 1 | |
processor: "./processor.js" | |
scenarios: | |
- name: "Load the options page" | |
flow: | |
- get: | |
url: "/some/endpoint" | |
afterResponse: "calculateResponseTimeDelta" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = { | |
calculateResponseTimeDelta: calculateResponseTimeDelta | |
}; | |
function calculateResponseTimeDelta(requestSpec, response, context, ee) { | |
// requestSpec will be the request spec for this response (currently always null) | |
// response is a Request.js response object | |
// context is the scenario context containing scenario variables | |
// ee is an event emitter for this scenario that we can use to add custom stats to the report | |
var responseTime = Number(response.headers['x-response-time'].split('ms')[0]); | |
ee.emit('customStat', { stat: 'response_time', value: responseTime }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to use breakpoints in the script?