question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I get response time for each request?

See original GitHub issue

Apologies if it’s not a right place to ask this question.

supertest
  .get('/something')
  .expect(200, function (res) {
      //console out time taken by '/something'
  })
  .end(done);

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

2reactions
muthukumarsivajothicommented, Mar 14, 2020

@rimiti @drptbl @naren-bhattarai did u find any solutions? I am still facing the same issue. i could not able to get response time for each requests.

1reaction
leosuncincommented, Oct 22, 2021

Examples using the performance measurement API

const { performance } = require('perf_hooks');

test('Response time under 100 ms', (done) => {
  const startTime = performance.now();

  supertest
    .get('/something')
    .expect(200, function (res) {
      expect(performance.now() - startTime).toBeLessThan(100);
      // other assertions
    })
    .end(done);
});
const { performance, PerformanceObserver } = require('perf_hooks');

const performanceObserver = new PerformanceObserver((items) => {
  for (const entry of items.getEntries()) {
    // send to your preferred logger
    console.log(entry.name, entry.duration);
  }

  performance.clearMarks();
});
performanceObserver.observe({ type: 'measure' });


test('Measure response time', async () => {
  performance.mark('Start request');

  await supertest
    .get('/something')
    .expect(200);
    
  performance.mark('End request');
  performance.measure('Response time', 'Start request', 'End request');
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to measure server response time for Python requests ...
If you need real request data, then you'd need to wrap the call to determine the time of each request: start = time.perf_counter()...
Read more >
5 Types of Response Time Metrics and How To Measure It
Response time testing is a measurement of the amount of time that passes between a user's request and a response from the server,...
Read more >
Response Time Testing – How to Measure for API? - Guru99
1. Method of calculating metrics gathered by each API response time test tool. 2. Tools Simulate the load and capture speed which can...
Read more >
What Is Response Time & How to Reduce It - Sematext
Response time refers to the amount of time it takes for a server to respond to a client's request. Measured in milliseconds, the...
Read more >
How can i calculate http response time for every http request?
The best way to do is keeping reference of your as is scenario use Jmeter or SOAP UI and hit the service for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found