diff --git a/src/core/components/live-response.jsx b/src/core/components/live-response.jsx index 550208fa..7c6f1384 100644 --- a/src/core/components/live-response.jsx +++ b/src/core/components/live-response.jsx @@ -8,11 +8,23 @@ const Headers = ( { headers } )=>{
{headers}
) } - Headers.propTypes = { headers: PropTypes.array.isRequired } +const Duration = ( { duration } ) => { + return ( +
+
Request duration
+
{duration} ms
+
+ ) +} +Duration.propTypes = { + duration: PropTypes.number.isRequired +} + + export default class LiveResponse extends React.Component { static propTypes = { response: PropTypes.object.isRequired, @@ -27,6 +39,7 @@ export default class LiveResponse extends React.Component { const headers = response.get("headers").toJS() const notDocumented = response.get("notDocumented") const isError = response.get("error") + const duration = response.get("duration") const body = isError ? response.get("response").get("text") : response.get("text") @@ -80,6 +93,9 @@ export default class LiveResponse extends React.Component { { hasHeaders ? : null } + { + duration ? : null + } diff --git a/src/core/plugins/spec/actions.js b/src/core/plugins/spec/actions.js index d531630a..9424891e 100644 --- a/src/core/plugins/spec/actions.js +++ b/src/core/plugins/spec/actions.js @@ -207,8 +207,14 @@ export const executeRequest = (req) => ({fn, specActions, specSelectors}) => { specActions.setRequest(req.pathName, req.method, parsedRequest) + // track duration of request + const startTime = Date.now() + return fn.execute(req) - .then( res => specActions.setResponse(req.pathName, req.method, res)) + .then( res => { + res.duration = Date.now() - startTime + specActions.setResponse(req.pathName, req.method, res) + } ) .catch( err => specActions.setResponse(req.pathName, req.method, { error: true, err: serializeError(err) } ) ) }