Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # http-timer
  2. > Timings for HTTP requests
  3. [![Build Status](https://travis-ci.org/szmarczak/http-timer.svg?branch=master)](https://travis-ci.org/szmarczak/http-timer)
  4. [![Coverage Status](https://coveralls.io/repos/github/szmarczak/http-timer/badge.svg?branch=master)](https://coveralls.io/github/szmarczak/http-timer?branch=master)
  5. [![install size](https://packagephobia.now.sh/badge?p=@szmarczak/http-timer)](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
  6. Inspired by the [`request` package](https://github.com/request/request).
  7. ## Usage
  8. ```js
  9. 'use strict';
  10. const https = require('https');
  11. const timer = require('@szmarczak/http-timer');
  12. const request = https.get('https://httpbin.org/anything');
  13. const timings = timer(request);
  14. request.on('response', response => {
  15. response.on('data', () => {}); // Consume the data somehow
  16. response.on('end', () => {
  17. console.log(timings);
  18. });
  19. });
  20. // { start: 1535708511443,
  21. // socket: 1535708511444,
  22. // lookup: 1535708511444,
  23. // connect: 1535708511582,
  24. // upload: 1535708511887,
  25. // response: 1535708512037,
  26. // end: 1535708512040,
  27. // phases:
  28. // { wait: 1,
  29. // dns: 0,
  30. // tcp: 138,
  31. // request: 305,
  32. // firstByte: 150,
  33. // download: 3,
  34. // total: 597 } }
  35. ```
  36. ## API
  37. ### timer(request)
  38. Returns: `Object`
  39. - `start` - Time when the request started.
  40. - `socket` - Time when a socket was assigned to the request.
  41. - `lookup` - Time when the DNS lookup finished.
  42. - `connect` - Time when the socket successfully connected.
  43. - `upload` - Time when the request finished uploading.
  44. - `response` - Time when the request fired the `response` event.
  45. - `end` - Time when the response fired the `end` event.
  46. - `error` - Time when the request fired the `error` event.
  47. - `phases`
  48. - `wait` - `timings.socket - timings.start`
  49. - `dns` - `timings.lookup - timings.socket`
  50. - `tcp` - `timings.connect - timings.lookup`
  51. - `request` - `timings.upload - timings.connect`
  52. - `firstByte` - `timings.response - timings.upload`
  53. - `download` - `timings.end - timings.response`
  54. - `total` - `timings.end - timings.start` or `timings.error - timings.start`
  55. **Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
  56. ## License
  57. MIT