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.browser.es.js 2.1KB

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