From 566ca93bad8613210489f0ad2cb433fd78ff2f33 Mon Sep 17 00:00:00 2001 From: Amaan Iqbal Date: Sat, 12 Jun 2021 05:02:21 +0530 Subject: [PATCH] Add response time in api response to test latency (#3465) * Add response time in api response to test latency * linting fixes Co-authored-by: Eric Reynolds --- packages/insomnia-app/app/common/send-request.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/insomnia-app/app/common/send-request.ts b/packages/insomnia-app/app/common/send-request.ts index 153e9f54be..93b4cbdb73 100644 --- a/packages/insomnia-app/app/common/send-request.ts +++ b/packages/insomnia-app/app/common/send-request.ts @@ -4,6 +4,10 @@ import { send } from '../network/network'; import { getBodyBuffer } from '../models/response'; import * as plugins from '../plugins'; +function toMs(num) { + return Math.round(num * 1000) / 1000; +} + export async function getSendRequestCallbackMemDb(environmentId, memDB) { // Initialize the DB in-memory and fill it with data if we're given one await db.init( @@ -55,6 +59,7 @@ async function sendAndTransform(requestId, environmentId) { statusMessage: res.statusMessage, data: bodyBuffer ? bodyBuffer.toString('utf8') : undefined, headers: headersObj, + responseTime: toMs(res.elapsedTime), }; } finally { plugins.clearIgnores();