# Global Metrics

path: .metrics.cyclomatic.sum
old: 27.0
new: 21.0
path: .metrics.cyclomatic.average
old: 9.0
new: 2.1
path: .metrics.cognitive.sum
old: 54.0
new: 7.0
path: .metrics.cognitive.average
old: 27.0
new: 0.875
path: .metrics.nargs.average
old: 1.5
new: 0.125
path: .metrics.nargs.sum
old: 3.0
new: 1.0
path: .metrics.nom.functions
old: 2.0
new: 8.0
path: .metrics.nom.total
old: 2.0
new: 8.0
path: .metrics.halstead.n2
old: 54.0
new: 44.0
path: .metrics.halstead.time
old: 34381.39492841175
new: 2055.0
path: .metrics.halstead.purity_ratio
old: 0.5032644428407504
new: 1.192166252254702
path: .metrics.halstead.N2
old: 383.0
new: 99.0
path: .metrics.halstead.level
old: 0.009399477806788513
new: 0.044444444444444446
path: .metrics.halstead.length
old: 910.0
new: 274.0
path: .metrics.halstead.effort
old: 618865.1087114115
new: 36990.0
path: .metrics.halstead.volume
old: 5817.008854728672
new: 1644.0
path: .metrics.halstead.N1
old: 527.0
new: 175.0
path: .metrics.halstead.vocabulary
old: 84.0
new: 64.0
path: .metrics.halstead.bugs
old: 2.420709887059256
new: 0.3700567237114785
path: .metrics.halstead.n1
old: 30.0
new: 20.0
path: .metrics.halstead.difficulty
old: 106.38888888888889
new: 22.5
path: .metrics.halstead.estimated_program_length
old: 457.97064298508286
new: 326.6535531177883
path: .metrics.mi.mi_sei
old: 5.764682687293021
new: 31.61139975264191
path: .metrics.mi.mi_visual_studio
old: 20.706828096786197
new: 33.505810978226
path: .metrics.mi.mi_original
old: 35.40867604550439
new: 57.29493677276646
path: .metrics.loc.blank
old: 3.0
new: 13.0
path: .metrics.loc.sloc
old: 182.0
new: 77.0
path: .metrics.loc.lloc
old: 89.0
new: 24.0
path: .metrics.loc.ploc
old: 153.0
new: 57.0
path: .metrics.loc.cloc
old: 26.0
new: 7.0
path: .metrics.nexits.sum
old: 6.0
new: 2.0
path: .metrics.nexits.average
old: 3.0
new: 0.25

# Spaces Data

## Minimal test - lines (9, 77)

path: .spaces[0].metrics.cyclomatic.average
old: 18.0
new: 2.2222222222222223
path: .spaces[0].metrics.cyclomatic.sum
old: 18.0
new: 20.0
path: .spaces[0].metrics.loc.cloc
old: 8.0
new: 1.0
path: .spaces[0].metrics.loc.sloc
old: 121.0
new: 69.0
path: .spaces[0].metrics.loc.lloc
old: 72.0
new: 24.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 12.0
path: .spaces[0].metrics.loc.ploc
old: 113.0
new: 56.0
path: .spaces[0].metrics.nargs.average
old: 2.0
new: 0.125
path: .spaces[0].metrics.nargs.sum
old: 2.0
new: 1.0
path: .spaces[0].metrics.nexits.average
old: 6.0
new: 0.25
path: .spaces[0].metrics.nexits.sum
old: 6.0
new: 2.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 8.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 8.0
path: .spaces[0].metrics.mi.mi_sei
old: 11.562363762155137
new: 21.217307077274683
path: .spaces[0].metrics.mi.mi_original
old: 45.77256082685139
new: 59.34080015917294
path: .spaces[0].metrics.mi.mi_visual_studio
old: 26.767579430907244
new: 34.70222231530581
path: .spaces[0].metrics.halstead.level
old: 0.012789968652037615
new: 0.04387755102040816
path: .spaces[0].metrics.halstead.bugs
old: 1.5892111836986462
new: 0.3713881022594225
path: .spaces[0].metrics.halstead.purity_ratio
old: 0.6459086205694381
new: 1.1713111587909797
path: .spaces[0].metrics.halstead.N1
old: 391.0
new: 175.0
path: .spaces[0].metrics.halstead.vocabulary
old: 80.0
new: 63.0
path: .spaces[0].metrics.halstead.effort
old: 329195.811635098
new: 37189.80164495739
path: .spaces[0].metrics.halstead.n2
old: 51.0
new: 43.0
path: .spaces[0].metrics.halstead.n1
old: 29.0
new: 20.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 430.1751412992458
new: 319.76794634993746
path: .spaces[0].metrics.halstead.time
old: 18288.65620194989
new: 2066.100091386522
path: .spaces[0].metrics.halstead.volume
old: 4210.404111194984
new: 1631.7974191154772
path: .spaces[0].metrics.halstead.N2
old: 275.0
new: 98.0
path: .spaces[0].metrics.halstead.length
old: 666.0
new: 273.0
path: .spaces[0].metrics.halstead.difficulty
old: 78.18627450980392
new: 22.79069767441861
path: .spaces[0].metrics.cognitive.average
old: 37.0
new: 0.875
path: .spaces[0].metrics.cognitive.sum
old: 37.0
new: 7.0

### Code

    namespace mozilla {

    StaticRefPtr InputTaskManager::gInputTaskManager;

    void InputTaskManager::EnableInputEventPrioritization() {
      MOZ_ASSERT(NS_IsMainThread());
      MOZ_ASSERT(mInputQueueState == STATE_DISABLED);
      mInputQueueState = STATE_ENABLED;
      mInputHandlingStartTime = TimeStamp();
    }

    void InputTaskManager::FlushInputEventPrioritization() {
      MOZ_ASSERT(NS_IsMainThread());
      MOZ_ASSERT(mInputQueueState == STATE_ENABLED ||
                 mInputQueueState == STATE_SUSPEND);
      mInputQueueState =
          mInputQueueState == STATE_ENABLED ? STATE_FLUSHING : STATE_SUSPEND;
    }

    void InputTaskManager::SuspendInputEventPrioritization() {
      MOZ_ASSERT(NS_IsMainThread());
      MOZ_ASSERT(mInputQueueState == STATE_ENABLED ||
                 mInputQueueState == STATE_FLUSHING);
      mInputQueueState = STATE_SUSPEND;
    }

    void InputTaskManager::ResumeInputEventPrioritization() {
      MOZ_ASSERT(NS_IsMainThread());
      MOZ_ASSERT(mInputQueueState == STATE_SUSPEND);
      mInputQueueState = STATE_ENABLED;
    }

    int32_t InputTaskManager::GetPriorityModifierForEventLoopTurn(
        const MutexAutoLock& aProofOfLock) {
      size_t inputCount = PendingTaskCount();
      if (State() == STATE_ENABLED && InputHandlingStartTime().IsNull() &&
          inputCount > 0) {
        SetInputHandlingStartTime(
            InputEventStatistics::Get().GetInputHandlingStartTime(inputCount));
      }

      if (inputCount > 0 && (State() == InputTaskManager::STATE_FLUSHING ||
                             (State() == InputTaskManager::STATE_ENABLED &&
                              !InputHandlingStartTime().IsNull() &&
                              TimeStamp::Now() > InputHandlingStartTime()))) {
        return 0;
      }

      int32_t modifier = static_cast(EventQueuePriority::InputLow) -
                         static_cast(EventQueuePriority::MediumHigh);
      return modifier;
    }

    void InputTaskManager::WillRunTask() {
      TaskManager::WillRunTask();
      mStartTimes.AppendElement(TimeStamp::Now());
    }

    void InputTaskManager::DidRunTask() {
      TaskManager::DidRunTask();
      MOZ_ASSERT(!mStartTimes.IsEmpty());
      TimeStamp start = mStartTimes.PopLastElement();
      InputEventStatistics::Get().UpdateInputDuration(TimeStamp::Now() - start);
    }

    // static
    void InputTaskManager::Init() { gInputTaskManager = new InputTaskManager(); }

    }  // namespace mozilla