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.

marky.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var marky = (function (exports) {
  2. 'use strict';
  3. /* global performance */
  4. var perf = typeof performance !== 'undefined' && performance;
  5. var now = perf && perf.now ? function () { return perf.now(); } : function () { return Date.now(); }
  6. function throwIfEmpty (name) {
  7. if (!name) {
  8. throw new Error('name must be non-empty')
  9. }
  10. }
  11. // simple binary sort insertion
  12. function insertSorted (arr, item) {
  13. var low = 0;
  14. var high = arr.length;
  15. var mid;
  16. while (low < high) {
  17. mid = (low + high) >>> 1; // like (num / 2) but faster
  18. if (arr[mid].startTime < item.startTime) {
  19. low = mid + 1;
  20. } else {
  21. high = mid;
  22. }
  23. }
  24. arr.splice(low, 0, item);
  25. }
  26. exports.mark = void 0;
  27. exports.stop = void 0;
  28. exports.getEntries = void 0;
  29. exports.clear = void 0;
  30. if (
  31. perf &&
  32. perf.mark &&
  33. perf.getEntriesByName &&
  34. perf.getEntriesByType &&
  35. perf.clearMeasures
  36. ) {
  37. exports.mark = function (name) {
  38. throwIfEmpty(name);
  39. perf.mark(("start " + name));
  40. };
  41. exports.stop = function (name) {
  42. throwIfEmpty(name);
  43. perf.mark(("end " + name));
  44. perf.measure(name, ("start " + name), ("end " + name));
  45. var entries = perf.getEntriesByName(name);
  46. return entries[entries.length - 1]
  47. };
  48. exports.getEntries = function () { return perf.getEntriesByType('measure'); };
  49. exports.clear = function () {
  50. perf.clearMarks();
  51. perf.clearMeasures();
  52. };
  53. } else {
  54. var marks = {};
  55. var entries = [];
  56. exports.mark = function (name) {
  57. throwIfEmpty(name);
  58. var startTime = now();
  59. marks['$' + name] = startTime;
  60. };
  61. exports.stop = function (name) {
  62. throwIfEmpty(name);
  63. var endTime = now();
  64. var startTime = marks['$' + name];
  65. if (!startTime) {
  66. throw new Error(("no known mark: " + name))
  67. }
  68. var entry = {
  69. startTime: startTime,
  70. name: name,
  71. duration: endTime - startTime,
  72. entryType: 'measure'
  73. };
  74. // per the spec this should be at least 150:
  75. // https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
  76. // we just have no limit, per Chrome and Edge's de-facto behavior
  77. insertSorted(entries, entry);
  78. return entry
  79. };
  80. exports.getEntries = function () { return entries; };
  81. exports.clear = function () {
  82. marks = {};
  83. entries = [];
  84. };
  85. }
  86. return exports;
  87. }({}));