Guest User

aboutPerformance.js.patch

a guest
May 7th, 2019
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- omni_ja_bak/chrome/toolkit/content/global/aboutPerformance.js   2010-01-01 00:00:00.000000000 +0200
  2. +++ omni_ja/chrome/toolkit/content/global/aboutPerformance.js   2019-05-07 18:58:41.345993002 +0300
  3. @@ -492,6 +492,8 @@
  4.    },
  5.  };
  6.  
  7. +let sort = '';
  8. +
  9.  var Control = {
  10.    _openItems: new Set(),
  11.    _removeSubtree(row) {
  12. @@ -636,6 +638,38 @@
  13.      this._openItems = new Set();
  14.  
  15.      let counters = this._sortCounters(State.getCounters());
  16. +    counters = counters.sort((a, b) => {
  17. +      let res = a.name > b.name;
  18. +      switch (sort) {
  19. +        case 'memory_asc':
  20. +          res = a.memory > b.memory;
  21. +          break;
  22. +        case 'memory_desc':
  23. +          res = a.memory < b.memory;
  24. +          break;
  25. +        case 'type_asc':
  26. +          res = a.type > b.type;
  27. +          break;
  28. +        case 'type_desc':
  29. +          res = a.type < b.type;
  30. +          break;
  31. +        case 'name_asc':
  32. +          res = a.name.toLowerCase() > b.name.toLowerCase();
  33. +          break;
  34. +        case 'name_desc':
  35. +          res = a.name.toLowerCase() < b.name.toLowerCase();
  36. +          break;
  37. +        case 'cpu_asc':
  38. +          res = this._computeEnergyImpact(a.dispatchesSincePrevious, a.durationSincePrevious) >
  39. +            this._computeEnergyImpact(b.dispatchesSincePrevious, b.durationSincePrevious)
  40. +          break;
  41. +        case 'cpu_desc':
  42. +          res = this._computeEnergyImpact(a.dispatchesSincePrevious, a.durationSincePrevious) <
  43. +            this._computeEnergyImpact(b.dispatchesSincePrevious, b.durationSincePrevious)
  44. +          break;
  45. +      }
  46. +      return res;
  47. +    });
  48.      for (let {id, name, image, type, totalDispatches, dispatchesSincePrevious,
  49.                memory, totalDuration, durationSincePrevious, children} of counters) {
  50.        let row =
  51. @@ -745,6 +779,25 @@
  52.    },
  53.  };
  54.  
  55. +document.addEventListener('DOMContentLoaded', () => {
  56. +  document.querySelector('td[data-l10n-id=column-type]').addEventListener('click', async () => {
  57. +    sort = sort === 'type_desc' ? 'type_asc' : 'type_desc';
  58. +    await Control._updateDisplay(true);
  59. +  });
  60. +  document.querySelector('td[data-l10n-id=column-energy-impact]').addEventListener('click', async () => {
  61. +    sort = sort === 'cpu_desc' ? 'cpu_asc' : 'cpu_desc';
  62. +    await Control._updateDisplay(true);
  63. +  });
  64. +  document.querySelector('td[data-l10n-id=column-memory]').addEventListener('click', async () => {
  65. +    sort = sort === 'memory_desc' ? 'memory_asc' : 'memory_desc';
  66. +    await Control._updateDisplay(true);
  67. +  });
  68. +  document.querySelector('td[data-l10n-id=column-name]').addEventListener('click', async () => {
  69. +    sort = sort === 'name_desc' ? 'name_asc' : 'name_desc';
  70. +    await Control._updateDisplay(true);
  71. +  });
  72. +});
  73. +
  74.  var go = async function() {
  75.    Control.init();
Advertisement
Add Comment
Please, Sign In to add comment