Global Metrics

path: .metrics.halstead.N1
old: 5176.0
new: 73.0

path: .metrics.halstead.estimated_program_length
old: 20632.212616852063
new: 266.18009270430093

path: .metrics.halstead.difficulty
old: 29.601483836777955
new: 8.75

path: .metrics.halstead.vocabulary
old: 1909.0
new: 54.0

path: .metrics.halstead.n2
old: 1887.0
new: 40.0

path: .metrics.halstead.bugs
old: 7.400546427133646
new: 0.11242047445227264

path: .metrics.halstead.N2
old: 5078.0
new: 50.0

path: .metrics.halstead.volume
old: 111754.25862643996
new: 707.8511627661065

path: .metrics.halstead.n1
old: 22.0
new: 14.0

path: .metrics.halstead.level
old: 0.0337820903004046
new: 0.11428571428571428

path: .metrics.halstead.time
old: 183782.88224564813
new: 344.094315233524

path: .metrics.halstead.effort
old: 3308091.8804216664
new: 6193.697674203432

path: .metrics.halstead.length
old: 10254.0
new: 123.0

path: .metrics.halstead.purity_ratio
old: 2.012113576833632
new: 2.16406579434391

path: .metrics.loc.blank
old: 22.0
new: 20.0

path: .metrics.loc.ploc
old: 380.0
new: 39.0

path: .metrics.loc.lloc
old: 17.0
new: 0.0

path: .metrics.loc.sloc
old: 416.0
new: 74.0

path: .metrics.loc.cloc
old: 14.0
new: 15.0

path: .metrics.nargs.sum
old: 6.0
new: 0.0

path: .metrics.nargs.average
old: 0.8571428571428571
new: 0.0

path: .metrics.nom.functions
old: 7.0
new: 1.0

path: .metrics.nom.total
old: 7.0
new: 1.0

path: .metrics.nexits.sum
old: 9.0
new: 0.0

path: .metrics.nexits.average
old: 1.2857142857142858
new: 0.0

path: .metrics.cognitive.sum
old: 4.0
new: 0.0

path: .metrics.cognitive.average
old: 0.5714285714285714
new: 0.0

path: .metrics.mi.mi_visual_studio
old: 5.636139858711265
new: 38.32779501323335

path: .metrics.mi.mi_sei
old: -46.35152185971246
new: 51.68151946141538

path: .metrics.mi.mi_original
old: 9.637799158396264
new: 65.54052947262903

path: .metrics.cyclomatic.average
old: 1.4
new: 1.1666666666666667

path: .metrics.cyclomatic.sum
old: 14.0
new: 7.0

Spaces Data

Minimal test - lines (19, 19)

path: .spaces[0].metrics.halstead.effort
old: 712.1703428566385
new: 0.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 43.65148445440323
new: null

path: .spaces[0].metrics.halstead.n2
old: 7.0
new: 1.0

path: .spaces[0].metrics.halstead.n1
old: 8.0
new: 0.0

path: .spaces[0].metrics.halstead.length
old: 29.0
new: 1.0

path: .spaces[0].metrics.halstead.time
old: 39.56501904759103
new: 0.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.5052236018759737
new: null

path: .spaces[0].metrics.halstead.N2
old: 11.0
new: 1.0

path: .spaces[0].metrics.halstead.difficulty
old: 6.285714285714286
new: 0.0

path: .spaces[0].metrics.halstead.vocabulary
old: 15.0
new: 1.0

path: .spaces[0].metrics.halstead.volume
old: 113.29982727264704
new: 0.0

path: .spaces[0].metrics.halstead.bugs
old: 0.026582837397255615
new: 0.0

path: .spaces[0].metrics.halstead.N1
old: 18.0
new: 0.0

path: .spaces[0].metrics.halstead.level
old: 0.1590909090909091
new: null

path: .spaces[0].metrics.nargs.average
old: 0.0
new: null

path: .spaces[0].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[0].metrics.nom.functions
old: 1.0
new: 0.0

path: .spaces[0].metrics.mi.mi_sei
old: 102.88519037207652
new: null

path: .spaces[0].metrics.mi.mi_original
old: 123.71583560355624
new: null

path: .spaces[0].metrics.mi.mi_visual_studio
old: 72.34844187342469
new: null

path: .spaces[0].metrics.nexits.average
old: 1.0
new: null

path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[0].metrics.cognitive.average
old: 0.0
new: null

path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 0.0

path: .spaces[0].metrics.loc.ploc
old: 4.0
new: 1.0

path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 1.0

Code

class nsIEventTarget;

Minimal test - lines (23, 25)

path: .spaces[1].spaces[0].metrics.halstead.level
old: 0.06015037593984962
new: 1.0

path: .spaces[1].spaces[0].metrics.halstead.n1
old: 14.0
new: 2.0

path: .spaces[1].spaces[0].metrics.halstead.length
old: 50.0
new: 4.0

path: .spaces[1].spaces[0].metrics.halstead.purity_ratio
old: 1.5460593781761292
new: 1.0

path: .spaces[1].spaces[0].metrics.halstead.vocabulary
old: 22.0
new: 4.0

path: .spaces[1].spaces[0].metrics.halstead.volume
old: 222.97158093186488
new: 8.0

path: .spaces[1].spaces[0].metrics.halstead.N1
old: 31.0
new: 2.0

path: .spaces[1].spaces[0].metrics.halstead.n2
old: 8.0
new: 2.0

path: .spaces[1].spaces[0].metrics.halstead.difficulty
old: 16.625
new: 1.0

path: .spaces[1].spaces[0].metrics.halstead.bugs
old: 0.07983981525612237
new: 0.0013333333333333333

path: .spaces[1].spaces[0].metrics.halstead.estimated_program_length
old: 77.30296890880646
new: 4.0

path: .spaces[1].spaces[0].metrics.halstead.effort
old: 3706.902532992254
new: 8.0

path: .spaces[1].spaces[0].metrics.halstead.time
old: 205.93902961068076
new: 0.4444444444444444

path: .spaces[1].spaces[0].metrics.halstead.N2
old: 19.0
new: 2.0

path: .spaces[1].spaces[0].metrics.nexits.average
old: 1.0
new: null

path: .spaces[1].spaces[0].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[1].spaces[0].metrics.mi.mi_original
old: 103.57746609809428
new: 142.15938490684147

path: .spaces[1].spaces[0].metrics.mi.mi_sei
old: 73.93348441436153
new: 129.49360748831728

path: .spaces[1].spaces[0].metrics.mi.mi_visual_studio
old: 60.57161760122472
new: 83.13414322037512

path: .spaces[1].spaces[0].metrics.loc.lloc
old: 4.0
new: 0.0

path: .spaces[1].spaces[0].metrics.loc.blank
old: 1.0
new: 0.0

path: .spaces[1].spaces[0].metrics.loc.ploc
old: 10.0
new: 3.0

path: .spaces[1].spaces[0].metrics.loc.sloc
old: 11.0
new: 3.0

path: .spaces[1].spaces[0].metrics.nargs.average
old: 2.0
new: null

path: .spaces[1].spaces[0].metrics.nargs.sum
old: 2.0
new: 0.0

path: .spaces[1].spaces[0].metrics.cognitive.average
old: 1.0
new: null

path: .spaces[1].spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0

path: .spaces[1].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 1.0

path: .spaces[1].spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0

path: .spaces[1].spaces[0].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[1].spaces[0].metrics.nom.functions
old: 1.0
new: 0.0

Code

namespace ipc {
enum class ResponseRejectReason;
}

Minimal test - lines (31, 70)

path: .spaces[1].spaces[1].metrics.nargs.sum
old: 1.0
new: 0.0

path: .spaces[1].spaces[1].metrics.nargs.average
old: 1.0
new: 0.0

path: .spaces[1].spaces[1].metrics.nexits.sum
old: 2.0
new: 0.0

path: .spaces[1].spaces[1].metrics.nexits.average
old: 2.0
new: 0.0

path: .spaces[1].spaces[1].metrics.cognitive.average
old: 1.0
new: 0.0

path: .spaces[1].spaces[1].metrics.cognitive.sum
old: 1.0
new: 0.0

path: .spaces[1].spaces[1].metrics.loc.ploc
old: 6.0
new: 23.0

path: .spaces[1].spaces[1].metrics.loc.blank
old: 1.0
new: 13.0

path: .spaces[1].spaces[1].metrics.loc.cloc
old: 0.0
new: 4.0

path: .spaces[1].spaces[1].metrics.loc.lloc
old: 3.0
new: 0.0

path: .spaces[1].spaces[1].metrics.loc.sloc
old: 7.0
new: 40.0

path: .spaces[1].spaces[1].metrics.mi.mi_visual_studio
old: 66.21237885190399
new: 45.30647788947181

path: .spaces[1].spaces[1].metrics.mi.mi_original
old: 113.22316783675583
new: 77.4740771909968

path: .spaces[1].spaces[1].metrics.mi.mi_sei
old: 87.8492904786226
new: 59.902866666045426

path: .spaces[1].spaces[1].metrics.halstead.difficulty
old: 7.944444444444445
new: 8.866666666666667

path: .spaces[1].spaces[1].metrics.halstead.purity_ratio
old: 2.017668873272457
new: 1.8916008186515283

path: .spaces[1].spaces[1].metrics.halstead.level
old: 0.12587412587412586
new: 0.11278195488721804

path: .spaces[1].spaces[1].metrics.halstead.n2
old: 9.0
new: 30.0

path: .spaces[1].spaces[1].metrics.halstead.length
old: 33.0
new: 106.0

path: .spaces[1].spaces[1].metrics.halstead.N1
old: 20.0
new: 68.0

path: .spaces[1].spaces[1].metrics.halstead.bugs
old: 0.03622836641198063
new: 0.09916411275728836

path: .spaces[1].spaces[1].metrics.halstead.effort
old: 1133.065482209637
new: 5131.137797303241

path: .spaces[1].spaces[1].metrics.halstead.n1
old: 11.0
new: 14.0

path: .spaces[1].spaces[1].metrics.halstead.estimated_program_length
old: 66.58307281799108
new: 200.50968677706203

path: .spaces[1].spaces[1].metrics.halstead.time
old: 62.94808234497983
new: 285.0632109612912

path: .spaces[1].spaces[1].metrics.halstead.vocabulary
old: 20.0
new: 44.0

path: .spaces[1].spaces[1].metrics.halstead.N2
old: 13.0
new: 38.0

path: .spaces[1].spaces[1].metrics.halstead.volume
old: 142.62362713128297
new: 578.6997515755535

path: .spaces[1].spaces[1].metrics.cyclomatic.average
old: 2.0
new: 1.5

path: .spaces[1].spaces[1].metrics.cyclomatic.sum
old: 2.0
new: 3.0

Code

class MemoryTelemetry final : public nsIObserver,
                              public nsSupportsWeakReference {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIOBSERVER

  static MemoryTelemetry& Get();

  nsresult GatherReports(
      const std::function& aCompletionCallback = nullptr);

  void GetUniqueSetSize(std::function&& aCallback);

  /**
   * Does expensive initialization, which should happen only after startup has
   * completed, and the event loop is idle.
   */
  nsresult DelayedInit();

  nsresult Shutdown();

 private:
  MemoryTelemetry();

  ~MemoryTelemetry() = default;

  void Init();

  static Result GetOpenTabsCount();

  void GatherTotalMemory();
  nsresult FinishGatheringTotalMemory(int64_t aTotalMemory,
                                      const nsTArray& aChildSizes);

  nsCOMPtr mThreadPool;

  bool mGatheringTotalMemory = false;

  TimeStamp mLastPoll{};
};

Minimal test - lines (21, 72)

path: .spaces[1].metrics.cyclomatic.average
old: 1.8
new: 1.25

path: .spaces[1].metrics.cyclomatic.sum
old: 9.0
new: 5.0

path: .spaces[1].metrics.nexits.sum
old: 6.0
new: 0.0

path: .spaces[1].metrics.nexits.average
old: 1.5
new: 0.0

path: .spaces[1].metrics.halstead.bugs
old: 6.4311144630512596
new: 0.10334218132151894

path: .spaces[1].metrics.halstead.vocabulary
old: 1884.0
new: 47.0

path: .spaces[1].metrics.halstead.length
old: 10135.0
new: 113.0

path: .spaces[1].metrics.halstead.N1
old: 5096.0
new: 72.0

path: .spaces[1].metrics.halstead.N2
old: 5039.0
new: 41.0

path: .spaces[1].metrics.halstead.n1
old: 18.0
new: 14.0

path: .spaces[1].metrics.halstead.difficulty
old: 24.30385852090032
new: 8.696969696969697

path: .spaces[1].metrics.halstead.purity_ratio
old: 2.0079444433581988
new: 1.9448493349348268

path: .spaces[1].metrics.halstead.effort
old: 2679854.6606782284
new: 5458.814274204772

path: .spaces[1].metrics.halstead.n2
old: 1866.0
new: 33.0

path: .spaces[1].metrics.halstead.time
old: 148880.8144821238
new: 303.2674596780429

path: .spaces[1].metrics.halstead.level
old: 0.04114572997287822
new: 0.11498257839721254

path: .spaces[1].metrics.halstead.volume
old: 110264.57623482557
new: 627.6685402395731

path: .spaces[1].metrics.halstead.estimated_program_length
old: 20350.516933435345
new: 219.76797484763543

path: .spaces[1].metrics.loc.lloc
old: 14.0
new: 0.0

path: .spaces[1].metrics.loc.sloc
old: 360.0
new: 52.0

path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 8.0

path: .spaces[1].metrics.loc.blank
old: 11.0
new: 16.0

path: .spaces[1].metrics.loc.ploc
old: 349.0
new: 28.0

path: .spaces[1].metrics.nargs.sum
old: 6.0
new: 0.0

path: .spaces[1].metrics.nargs.average
old: 1.5
new: 0.0

path: .spaces[1].metrics.mi.mi_visual_studio
old: 7.719179599333593
new: 42.304905373778475

path: .spaces[1].metrics.mi.mi_sei
old: -55.741191419022954
new: 57.72153276987409

path: .spaces[1].metrics.mi.mi_original
old: 13.199797114860443
new: 72.3413881891612

path: .spaces[1].metrics.nom.functions
old: 4.0
new: 1.0

path: .spaces[1].metrics.nom.total
old: 4.0
new: 1.0

path: .spaces[1].metrics.cognitive.average
old: 1.0
new: 0.0

path: .spaces[1].metrics.cognitive.sum
old: 4.0
new: 0.0

Code

namespace mozilla {

namespace ipc {
enum class ResponseRejectReason;
}

/**
 * Periodically gathers memory usage metrics after cycle collection, and
 * populates telemetry histograms with their values.
 */
class MemoryTelemetry final : public nsIObserver,
                              public nsSupportsWeakReference {
 public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIOBSERVER

  static MemoryTelemetry& Get();

  nsresult GatherReports(
      const std::function& aCompletionCallback = nullptr);

  void GetUniqueSetSize(std::function&& aCallback);

  /**
   * Does expensive initialization, which should happen only after startup has
   * completed, and the event loop is idle.
   */
  nsresult DelayedInit();

  nsresult Shutdown();

 private:
  MemoryTelemetry();

  ~MemoryTelemetry() = default;

  void Init();

  static Result GetOpenTabsCount();

  void GatherTotalMemory();
  nsresult FinishGatheringTotalMemory(int64_t aTotalMemory,
                                      const nsTArray& aChildSizes);

  nsCOMPtr mThreadPool;

  bool mGatheringTotalMemory = false;

  TimeStamp mLastPoll{};
};

}  // namespace mozilla