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.cjs.js 2.6KB

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