mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-09 06:20:08 +01:00
Merge pull request #391 from dozed/show-response-time
Show response time in milliseconds per request and total
This commit is contained in:
commit
c8764f6555
@ -356,7 +356,8 @@ const handler = async function (argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const summary = printRunSummary(results);
|
const summary = printRunSummary(results);
|
||||||
console.log(chalk.dim(chalk.grey('Ran all requests.')));
|
const totalTime = results.reduce((acc, res) => acc + res.response.responseTime, 0);
|
||||||
|
console.log(chalk.dim(chalk.grey(`Ran all requests - ${totalTime} ms`)));
|
||||||
|
|
||||||
if (outputPath && outputPath.length) {
|
if (outputPath && outputPath.length) {
|
||||||
const outputDir = path.dirname(outputPath);
|
const outputDir = path.dirname(outputPath);
|
||||||
|
@ -122,13 +122,16 @@ const runSingleRequest = async function (
|
|||||||
request.data = qs.stringify(request.data);
|
request.data = qs.stringify(request.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
let response;
|
let response, responseTime;
|
||||||
try {
|
try {
|
||||||
// run request
|
// run request
|
||||||
|
const start = Date.now();
|
||||||
response = await axios(request);
|
response = await axios(request);
|
||||||
|
responseTime = Date.now() - start;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err && err.response) {
|
if (err && err.response) {
|
||||||
response = err.response;
|
response = err.response;
|
||||||
|
responseTime = Date.now() - start;
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.red(stripExtension(filename)) + chalk.dim(` (${err.message})`));
|
console.log(chalk.red(stripExtension(filename)) + chalk.dim(` (${err.message})`));
|
||||||
return {
|
return {
|
||||||
@ -142,7 +145,8 @@ const runSingleRequest = async function (
|
|||||||
status: null,
|
status: null,
|
||||||
statusText: null,
|
statusText: null,
|
||||||
headers: null,
|
headers: null,
|
||||||
data: null
|
data: null,
|
||||||
|
responseTime: 0
|
||||||
},
|
},
|
||||||
error: err.message,
|
error: err.message,
|
||||||
assertionResults: [],
|
assertionResults: [],
|
||||||
@ -151,7 +155,10 @@ const runSingleRequest = async function (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(chalk.green(stripExtension(filename)) + chalk.dim(` (${response.status} ${response.statusText})`));
|
console.log(
|
||||||
|
chalk.green(stripExtension(filename)) +
|
||||||
|
chalk.dim(` (${response.status} ${response.statusText}) - ${responseTime} ms`)
|
||||||
|
);
|
||||||
|
|
||||||
// run post-response vars
|
// run post-response vars
|
||||||
const postResponseVars = get(bruJson, 'request.vars.res');
|
const postResponseVars = get(bruJson, 'request.vars.res');
|
||||||
@ -247,7 +254,8 @@ const runSingleRequest = async function (
|
|||||||
status: response.status,
|
status: response.status,
|
||||||
statusText: response.statusText,
|
statusText: response.statusText,
|
||||||
headers: response.headers,
|
headers: response.headers,
|
||||||
data: response.data
|
data: response.data,
|
||||||
|
responseTime
|
||||||
},
|
},
|
||||||
error: null,
|
error: null,
|
||||||
assertionResults,
|
assertionResults,
|
||||||
|
Loading…
Reference in New Issue
Block a user