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 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. marky [![Build status](https://circleci.com/gh/nolanlawson/marky.svg?style=svg)](https://app.circleci.com/pipelines/gh/nolanlawson/marky)
  2. ======
  3. JavaScript timer based on `performance.mark()` and `performance.measure()`, providing [high-resolution
  4. timings](https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API) as well as nice Dev Tools visualizations.
  5. For browsers that don't support `performance.mark()`, it falls back to
  6. `performance.now()` or `Date.now()`. In Node, it uses `process.hrtime()`.
  7. Quick start
  8. ----
  9. Install via npm:
  10. npm install marky
  11. Or as a script tag:
  12. ```html
  13. <script src="https://unpkg.com/marky/dist/marky.min.js"></script>
  14. ```
  15. Then take some measurements:
  16. ```js
  17. var marky = require('marky');
  18. marky.mark('expensive operation');
  19. doExpensiveOperation();
  20. marky.stop('expensive operation');
  21. ```
  22. Why?
  23. ---
  24. The [User Timing API](https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API) is [more performant](https://gist.github.com/paulirish/2fad3834e2617fb199bc12e17058dde4)
  25. than `console.time()` and `console.timeEnd()`,
  26. and [more accurate](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) than `Date.now()`. Also, you get nice visualizations in Chrome Dev Tools:
  27. ![Chrome Dev Tools screenshot](doc/chrome.png)
  28. As well as Edge F12 Tools:
  29. ![Edge F12 screenshot](doc/edge.png)
  30. This is because `marky` adds standard
  31. [PerformanceEntries](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) to the [Performance Timeline](https://developer.mozilla.org/en-US/docs/Web/API/Performance_Timeline). Tools like [WebPageTest](http://blog.patrickmeenan.com/2013/07/measuring-performance-of-user-experience.html) and [Windows Performance Analyzer](https://blogs.windows.com/msedgedev/2016/05/11/top-down-analysis-wpt/) also surface them, and you can even [send them to your analytics provider](https://codelabs.developers.google.com/codelabs/performance-analytics/index.html).
  32. API
  33. ---
  34. `marky.mark()` begins recording, and `marky.stop()` finishes recording:
  35. ```js
  36. marky.mark('releaseTheHounds');
  37. releaseTheHounds();
  38. marky.stop('releaseTheHounds');
  39. ```
  40. You can also do more complex scenarios:
  41. ```js
  42. function setSail() {
  43. marky.mark('setSail');
  44. marky.mark('raiseTheAnchor');
  45. raiseTheAnchor();
  46. marky.stop('raiseTheAnchor');
  47. marky.mark('unfurlTheSails');
  48. unfurlTheSails();
  49. marky.stop('unfurlTheSails');
  50. marky.stop('setSail');
  51. }
  52. ```
  53. `marky.stop()` also returns a `PerformanceEntry`:
  54. ```js
  55. marky.mark('manTheTorpedos');
  56. manTheTorpedos();
  57. var entry = marky.stop('manTheTorpedos');
  58. ```
  59. The entry will look something like:
  60. ```json
  61. {
  62. "entryType": "measure",
  63. "startTime": 1974112,
  64. "duration": 350,
  65. "name": "manTheTorpedos"
  66. }
  67. ```
  68. You can get all entries using:
  69. ```js
  70. var entries = marky.getEntries();
  71. ```
  72. This provides a list of all measures ordered by `startTime`, e.g.:
  73. ```json
  74. [
  75. {
  76. "entryType": "measure",
  77. "startTime": 1974112,
  78. "duration": 350,
  79. "name": "numberOne"
  80. },
  81. {
  82. "entryType": "measure",
  83. "startTime": 1975108,
  84. "duration": 300,
  85. "name": "numberTwo"
  86. },
  87. {
  88. "entryType": "measure",
  89. "startTime": 1976127,
  90. "duration": 250,
  91. "name": "numberThree"
  92. }
  93. ]
  94. ```
  95. You can also clear the entries using `marky.clear():`
  96. ```js
  97. marky.clear()
  98. ```
  99. After this, `marky.getEntries()` will return an empty list. (If the User Timing API is supported, this will delete all the `mark` and `measure` entries from the timeline.)
  100. Browser support
  101. ----
  102. `marky` has been tested in the following browsers/environments:
  103. * IE 9+
  104. * Safari 8+
  105. * iOS 8+
  106. * Android 4.4+
  107. * Chrome
  108. * Firefox
  109. * Edge
  110. * Node 4+
  111. Per [the spec](https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface), browsers only need to hold a minimum
  112. of 150 entries in their Performance Timeline buffer. [In older versions of Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1331135), the buffer
  113. is throttled to 150, which for `marky`
  114. means you can get a maximum of 50 entries from `marky.getEntries()` (because `marky` creates two marks and a measure).
  115. If you need to get more than 50 entries from `marky.getEntries()`, you can do:
  116. ```js
  117. if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
  118. performance.setResourceTimingBufferSize(10000); // or however many you need
  119. }
  120. ```
  121. In Node and [browsers that don't support the User Timing API](http://caniuse.com/#feat=user-timing),
  122. `marky` follows the behavior of Edge and Chrome, and does not limit the number of entries. `marky.stop()` and
  123. `marky.getEntries()` will return pseudo-`PerformanceEntry` objects.
  124. See also
  125. ---
  126. - [appmetrics.js](https://github.com/ebidel/appmetrics.js) – a library on top of `mark()`/`measure()` which reports to Google Analytics.
  127. Credits
  128. ----
  129. Thanks to [@toddreifsteck](https://github.com/toddreifsteck) for feedback on this project and clarifications on the User Timing API.