# Global Metrics

path: .metrics.cognitive.average
old: null
new: 5.6
path: .metrics.cognitive.sum
old: 0.0
new: 28.0
path: .metrics.nom.total
old: 0.0
new: 5.0
path: .metrics.nom.functions
old: 0.0
new: 5.0
path: .metrics.nargs.average
old: null
new: 1.8
path: .metrics.nargs.sum
old: 0.0
new: 9.0
path: .metrics.cyclomatic.sum
old: 6.0
new: 29.0
path: .metrics.cyclomatic.average
old: 1.0
new: 2.4166666666666665
path: .metrics.halstead.vocabulary
old: 44.0
new: 90.0
path: .metrics.halstead.bugs
old: 0.09978797854455994
new: 0.7166207306026421
path: .metrics.halstead.level
old: 0.11594202898550723
new: 0.03197674418604651
path: .metrics.halstead.effort
old: 5179.635748182135
new: 99681.81412567888
path: .metrics.halstead.difficulty
old: 8.625
new: 31.272727272727273
path: .metrics.halstead.time
old: 287.75754156567416
new: 5537.878562537715
path: .metrics.halstead.N2
old: 46.0
new: 172.0
path: .metrics.halstead.length
old: 110.0
new: 491.0
path: .metrics.halstead.volume
old: 600.5374780501027
new: 3187.4998702978705
path: .metrics.halstead.estimated_program_length
old: 203.01955000865388
new: 508.9691118949657
path: .metrics.halstead.N1
old: 64.0
new: 319.0
path: .metrics.halstead.n2
old: 32.0
new: 66.0
path: .metrics.halstead.purity_ratio
old: 1.8456322728059444
new: 1.0365969692361827
path: .metrics.halstead.n1
old: 12.0
new: 24.0
path: .metrics.nexits.sum
old: 0.0
new: 6.0
path: .metrics.nexits.average
old: null
new: 1.2
path: .metrics.mi.mi_visual_studio
old: 43.26252548959169
new: 25.238587689575045
path: .metrics.mi.mi_original
old: 73.97891858720179
new: 43.157984949173326
path: .metrics.mi.mi_sei
old: 61.46469292590393
new: 17.148211931741816
path: .metrics.loc.sloc
old: 47.0
new: 133.0
path: .metrics.loc.ploc
old: 28.0
new: 103.0
path: .metrics.loc.lloc
old: 0.0
new: 30.0
path: .metrics.loc.cloc
old: 8.0
new: 19.0

# Spaces Data

## Minimal test - lines (72, 106)

path: .spaces[1].metrics.cognitive.average
old: null
new: 16.0
path: .spaces[1].metrics.cognitive.sum
old: 0.0
new: 16.0
path: .spaces[1].metrics.nexits.average
old: null
new: 2.0
path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[1].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[1].metrics.halstead.effort
old: 4888.304346282569
new: 8530.179581050725
path: .spaces[1].metrics.halstead.estimated_program_length
old: 183.90099886735345
new: 168.0419249893113
path: .spaces[1].metrics.halstead.n2
old: 29.0
new: 23.0
path: .spaces[1].metrics.halstead.vocabulary
old: 41.0
new: 39.0
path: .spaces[1].metrics.halstead.bugs
old: 0.09601024327787588
new: 0.13916099589881023
path: .spaces[1].metrics.halstead.N2
old: 42.0
new: 40.0
path: .spaces[1].metrics.halstead.time
old: 271.57246368236497
new: 473.8988656139291
path: .spaces[1].metrics.halstead.length
old: 105.0
new: 116.0
path: .spaces[1].metrics.halstead.difficulty
old: 8.689655172413794
new: 13.91304347826087
path: .spaces[1].metrics.halstead.level
old: 0.11507936507936509
new: 0.07187500000000001
path: .spaces[1].metrics.halstead.volume
old: 562.5429604848988
new: 613.1066573880208
path: .spaces[1].metrics.halstead.n1
old: 12.0
new: 16.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.7514380844509851
new: 1.4486372843906146
path: .spaces[1].metrics.halstead.N1
old: 63.0
new: 76.0
path: .spaces[1].metrics.loc.lloc
old: 0.0
new: 13.0
path: .spaces[1].metrics.loc.ploc
old: 23.0
new: 27.0
path: .spaces[1].metrics.loc.sloc
old: 32.0
new: 35.0
path: .spaces[1].metrics.loc.blank
old: 8.0
new: 2.0
path: .spaces[1].metrics.loc.cloc
old: 1.0
new: 6.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nargs.average
old: null
new: 2.0
path: .spaces[1].metrics.mi.mi_visual_studio
old: 47.37207447180408
new: 45.58886494434368
path: .spaces[1].metrics.mi.mi_sei
old: 55.096280129627694
new: 67.6006153750648
path: .spaces[1].metrics.mi.mi_original
old: 81.00624734678497
new: 77.95695905482769
path: .spaces[1].metrics.cyclomatic.sum
old: 4.0
new: 9.0
path: .spaces[1].metrics.cyclomatic.average
old: 1.0
new: 9.0

### Code

    already_AddRefed EventQueueInternal::GetEvent(
        const MutexAutoLock& aProofOfLock, mozilla::TimeDuration* aLastEventDelay) {
      if (mQueue.IsEmpty()) {
        if (aLastEventDelay) {
          *aLastEventDelay = TimeDuration();
        }
        return nullptr;
      }

    #ifdef MOZ_GECKO_PROFILER
      // We always want to clear the dispatch times, even if the profiler is turned
      // off, because we want to empty the (previously-collected) dispatch times, if
      // any, from when the profiler was turned on.  We only want to do something
      // interesting with the dispatch times if the profiler is turned on, though.
      if (!mDispatchTimes.IsEmpty()) {
        TimeStamp dispatch_time = mDispatchTimes.Pop();
        if (profiler_is_active()) {
          if (!dispatch_time.IsNull()) {
            if (aLastEventDelay) {
              *aLastEventDelay = TimeStamp::Now() - dispatch_time;
            }
          }
        }
      } else if (profiler_is_active()) {
        if (aLastEventDelay) {
          // if we just turned on the profiler, we don't have dispatch
          // times for events already in the queue.
          *aLastEventDelay = TimeDuration();
        }
      }
    #endif

      nsCOMPtr result = mQueue.Pop();
      return result.forget();
    }

## Minimal test - lines (18, 69)

path: .spaces[0].metrics.cognitive.average
old: null
new: 12.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 12.0
path: .spaces[0].metrics.nexits.average
old: null
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.mi.mi_sei
old: null
new: 35.90722025789188
path: .spaces[0].metrics.mi.mi_original
old: null
new: 66.28664633498343
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 38.764120663733
path: .spaces[0].metrics.nargs.average
old: null
new: 4.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 4.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 10.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 10.0
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 178.0
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.3465785122822833
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 263.0
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 47.0
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.388241828966389
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 1862.566668089544
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 85.0
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 33526.2000256118
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 70.0
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 1612.0014334565262
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 365.10760101816027
path: .spaces[0].metrics.halstead.level
old: null
new: 0.04808184143222507
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 23.0
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 20.79787234042553
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 44.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 52.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 6.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 14.0

### Code

    void EventQueueInternal::PutEvent(
        already_AddRefed&& aEvent, EventQueuePriority aPriority,
        const MutexAutoLock& aProofOfLock, mozilla::TimeDuration* aDelay) {
      nsCOMPtr event(aEvent);

      static_assert(static_cast(nsIRunnablePriority::PRIORITY_IDLE) ==
                    static_cast(EventQueuePriority::Idle));
      static_assert(static_cast(nsIRunnablePriority::PRIORITY_NORMAL) ==
                    static_cast(EventQueuePriority::Normal));
      static_assert(
          static_cast(nsIRunnablePriority::PRIORITY_MEDIUMHIGH) ==
          static_cast(EventQueuePriority::MediumHigh));
      static_assert(
          static_cast(nsIRunnablePriority::PRIORITY_INPUT_HIGH) ==
          static_cast(EventQueuePriority::InputHigh));
      static_assert(static_cast(nsIRunnablePriority::PRIORITY_HIGH) ==
                    static_cast(EventQueuePriority::High));

      if (mForwardToTC) {
        TaskController* tc = TaskController::Get();

        TaskManager* manager = nullptr;
        if (aPriority == EventQueuePriority::InputHigh) {
          if (InputTaskManager::Get()->State() ==
              InputTaskManager::STATE_DISABLED) {
            aPriority = EventQueuePriority::Normal;
          } else {
            manager = InputTaskManager::Get();
          }
        } else if (aPriority == EventQueuePriority::DeferredTimers ||
                   aPriority == EventQueuePriority::Idle) {
          manager = TaskController::Get()->GetIdleTaskManager();
        }

        tc->DispatchRunnable(event.forget(), static_cast(aPriority),
                             manager);
        return;
      }

    #ifdef MOZ_GECKO_PROFILER
      // Sigh, this doesn't check if this thread is being profiled
      if (profiler_is_active()) {
        // check to see if the profiler has been enabled since the last PutEvent
        while (mDispatchTimes.Count() < mQueue.Count()) {
          mDispatchTimes.Push(TimeStamp());
        }
        mDispatchTimes.Push(aDelay ? TimeStamp::Now() - *aDelay : TimeStamp::Now());
      }
    #endif

      mQueue.Push(std::move(event));
    }