# Global Metrics

path: .metrics.nom.functions
old: 7.0
new: 13.0
path: .metrics.nom.total
old: 7.0
new: 13.0
path: .metrics.cognitive.sum
old: 3.0
new: 1.0
path: .metrics.cognitive.average
old: 0.42857142857142855
new: 0.07692307692307693
path: .metrics.cyclomatic.sum
old: 13.0
new: 19.0
path: .metrics.cyclomatic.average
old: 1.3
new: 1.1875
path: .metrics.loc.ploc
old: 76.0
new: 83.0
path: .metrics.loc.blank
old: 23.0
new: 28.0
path: .metrics.loc.cloc
old: 11.0
new: 17.0
path: .metrics.loc.lloc
old: 19.0
new: 34.0
path: .metrics.loc.sloc
old: 110.0
new: 128.0
path: .metrics.nargs.average
old: 1.2857142857142858
new: 0.3076923076923077
path: .metrics.nargs.sum
old: 9.0
new: 4.0
path: .metrics.halstead.volume
old: 2061.3363046539125
new: 2362.578525841978
path: .metrics.halstead.bugs
old: 0.4721279723249811
new: 0.5216909581535455
path: .metrics.halstead.estimated_program_length
old: 430.5822264174108
new: 420.47352047282726
path: .metrics.halstead.n1
old: 22.0
new: 19.0
path: .metrics.halstead.difficulty
old: 25.859649122807017
new: 26.20689655172414
path: .metrics.halstead.time
old: 2961.4129756918783
new: 3439.769501225868
path: .metrics.halstead.N1
old: 193.0
new: 217.0
path: .metrics.halstead.level
old: 0.03867028493894165
new: 0.038157894736842106
path: .metrics.halstead.vocabulary
old: 79.0
new: 77.0
path: .metrics.halstead.purity_ratio
old: 1.316765218401868
new: 1.1153143779120087
path: .metrics.halstead.n2
old: 57.0
new: 58.0
path: .metrics.halstead.effort
old: 53305.43356245381
new: 61915.851022065624
path: .metrics.halstead.N2
old: 134.0
new: 160.0
path: .metrics.halstead.length
old: 327.0
new: 377.0
path: .metrics.nexits.average
old: 0.5714285714285714
new: 0.15384615384615383
path: .metrics.nexits.sum
old: 4.0
new: 2.0
path: .metrics.mi.mi_original
old: 52.18044741028329
new: 47.63606345871305
path: .metrics.mi.mi_sei
old: 24.43007100937332
new: 21.711068372795506
path: .metrics.mi.mi_visual_studio
old: 30.51488152648146
new: 27.85734705187898

# Spaces Data

## Minimal test - lines (62, 71)

path: .spaces[0].spaces[0].spaces[5].metrics.cognitive.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].spaces[5].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].spaces[5].metrics.loc.ploc
old: 4.0
new: 9.0
path: .spaces[0].spaces[0].spaces[5].metrics.loc.lloc
old: 1.0
new: 5.0
path: .spaces[0].spaces[0].spaces[5].metrics.loc.sloc
old: 4.0
new: 10.0
path: .spaces[0].spaces[0].spaces[5].metrics.loc.blank
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].spaces[5].metrics.nargs.sum
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[5].metrics.nargs.average
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[5].metrics.cyclomatic.average
old: 1.0
new: 2.0
path: .spaces[0].spaces[0].spaces[5].metrics.cyclomatic.sum
old: 1.0
new: 2.0
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.length
old: 21.0
new: 37.0
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.vocabulary
old: 14.0
new: 20.0
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.N1
old: 13.0
new: 21.0
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.estimated_program_length
old: 39.50977500432694
new: 67.01955000865388
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.bugs
old: 0.018884536768029512
new: 0.029977637572122715
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.n2
old: 6.0
new: 12.0
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.time
old: 23.690208403913985
new: 47.381137632839234
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.purity_ratio
old: 1.881417857348902
new: 1.811339189423078
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.effort
old: 426.4237512704517
new: 852.8604773911062
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.volume
old: 79.9544533632097
new: 159.91133951083242
path: .spaces[0].spaces[0].spaces[5].metrics.halstead.N2
old: 8.0
new: 16.0
path: .spaces[0].spaces[0].spaces[5].metrics.mi.mi_sei
old: 105.50024626685564
new: 78.65489699817395
path: .spaces[0].spaces[0].spaces[5].metrics.mi.mi_original
old: 125.52845422402903
new: 106.85009991882409
path: .spaces[0].spaces[0].spaces[5].metrics.mi.mi_visual_studio
old: 73.40845276259009
new: 62.48543854901993
path: .spaces[0].spaces[0].spaces[5].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[5].metrics.nexits.sum
old: 1.0
new: 0.0

### Code

    void TracedTaskCommon::DoSetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      if (mIsTraceInfoInit) {
        info->mCurTraceSourceId = mSourceEventId;
        info->mCurTraceSourceType = mSourceEventType;
        info->mCurTaskId = mTaskId;
      }
    }

## Minimal test - lines (31, 44)

path: .spaces[0].spaces[0].spaces[2].metrics.loc.ploc
old: 1.0
new: 10.0
path: .spaces[0].spaces[0].spaces[2].metrics.loc.lloc
old: 1.0
new: 6.0
path: .spaces[0].spaces[0].spaces[2].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[0].spaces[0].spaces[2].metrics.loc.blank
old: 0.0
new: 2.0
path: .spaces[0].spaces[0].spaces[2].metrics.loc.sloc
old: 1.0
new: 14.0
path: .spaces[0].spaces[0].spaces[2].metrics.nargs.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[2].metrics.nargs.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.bugs
old: 0.008859751325042116
new: 0.032812746511079204
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.time
old: 7.612751884116872
new: 54.25918325416303
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.vocabulary
old: 10.0
new: 23.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.purity_ratio
old: 2.1372522731206307
new: 1.7798188181787922
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.estimated_program_length
old: 23.509775004326936
new: 83.65148445440323
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.n2
old: 4.0
new: 16.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.N1
old: 6.0
new: 26.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.difficulty
old: 3.75
new: 4.59375
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.volume
old: 36.541209043760986
new: 212.6074119346796
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.length
old: 11.0
new: 47.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.level
old: 0.26666666666666666
new: 0.21768707482993196
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.effort
old: 137.0295339141037
new: 976.6652985749344
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.N2
old: 5.0
new: 21.0
path: .spaces[0].spaces[0].spaces[2].metrics.halstead.n1
old: 6.0
new: 7.0
path: .spaces[0].spaces[0].spaces[2].metrics.mi.mi_sei
old: 143.77444718573403
new: 96.51667737190095
path: .spaces[0].spaces[0].spaces[2].metrics.mi.mi_visual_studio
old: 88.92287057259325
new: 58.566166755311734
path: .spaces[0].spaces[0].spaces[2].metrics.mi.mi_original
old: 152.05810867913445
new: 100.14814515158308

### Code

    void TracedTaskCommon::Init() {
      // Keep the following line before GetOrCreateTraceInfo() to avoid a
      // deadlock.
      uint64_t taskid = GenNewUniqueTaskId();

      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      mTaskId = taskid;
      mSourceEventId = info->mCurTraceSourceId;
      mSourceEventType = info->mCurTraceSourceType;
      mParentTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

## Minimal test - lines (29, 29)

path: .spaces[0].spaces[0].spaces[1].metrics.mi.mi_original
old: 126.22876917047284
new: 158.02045369261705
path: .spaces[0].spaces[0].spaces[1].metrics.mi.mi_visual_studio
old: 73.81799366694318
new: 92.40962204246613
path: .spaces[0].spaces[0].spaces[1].metrics.mi.mi_sei
old: 138.4460777000009
new: 152.37629276875444
path: .spaces[0].spaces[0].spaces[1].metrics.loc.ploc
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].spaces[1].metrics.loc.lloc
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[1].metrics.loc.cloc
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[1].metrics.loc.sloc
old: 5.0
new: 1.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.volume
old: 34.86917501586544
new: 11.60964047443681
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.effort
old: 87.1729375396636
new: 23.21928094887362
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.vocabulary
old: 9.0
new: 5.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.difficulty
old: 2.5
new: 2.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.n1
old: 5.0
new: 4.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.N2
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.level
old: 0.4
new: 0.5
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.n2
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.N1
old: 7.0
new: 4.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.length
old: 11.0
new: 5.0
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.time
old: 4.842940974425755
new: 1.289960052715201
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.bugs
old: 0.006553397824358721
new: 0.002712967490108627
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.purity_ratio
old: 1.7826945885851644
new: 1.6
path: .spaces[0].spaces[0].spaces[1].metrics.halstead.estimated_program_length
old: 19.60964047443681
new: 8.0

### Code

    TracedTaskCommon::~TracedTaskCommon() {}

## Minimal test - lines (22, 27)

path: .spaces[0].spaces[0].spaces[0].metrics.loc.ploc
old: 1.0
new: 6.0
path: .spaces[0].spaces[0].spaces[0].metrics.loc.sloc
old: 1.0
new: 6.0
path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 91.0600994256245
new: 69.03700693539412
path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_original
old: 155.7127700178179
new: 118.05328185952392
path: .spaces[0].spaces[0].spaces[0].metrics.mi.mi_sei
old: 149.04700897518126
new: 94.71585216679392
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.level
old: 0.6666666666666666
new: 0.32727272727272727
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.n1
old: 3.0
new: 5.0
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.n2
old: 3.0
new: 9.0
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.N1
old: 4.0
new: 14.0
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.3585392863324195
new: 1.6055586194967049
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.time
old: 1.5078947920873411
new: 16.157756227867917
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.volume
old: 18.094737505048094
new: 95.1838730514401
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.effort
old: 27.14210625757214
new: 290.8396121016225
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.difficulty
old: 1.5
new: 3.0555555555555554
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 9.509775004326936
new: 40.13896548741762
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.vocabulary
old: 6.0
new: 14.0
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.N2
old: 3.0
new: 11.0
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.bugs
old: 0.003010517177243676
new: 0.014632362433554097
path: .spaces[0].spaces[0].spaces[0].metrics.halstead.length
old: 7.0
new: 25.0

### Code

    TracedTaskCommon::TracedTaskCommon()
        : mSourceEventType(SourceEventType::Unknown),
          mSourceEventId(0),
          mParentTaskId(0),
          mTaskId(0),
          mIsTraceInfoInit(false) {}

## Minimal test - lines (51, 60)

path: .spaces[0].spaces[0].spaces[4].metrics.halstead.effort
old: 2082.7695011139635
new: 1016.7504090493038
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.time
old: 115.70941672855352
new: 56.48613383607243
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.N2
old: 18.0
new: 19.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.n1
old: 13.0
new: 8.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.volume
old: 213.6173847296373
new: 187.29612798276648
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.N1
old: 28.0
new: 23.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.estimated_program_length
old: 91.12526634448808
new: 77.30296890880646
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.purity_ratio
old: 1.980984050967132
new: 1.8405468787811063
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.bugs
old: 0.054363350891400104
new: 0.03370453313589997
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.n2
old: 12.0
new: 14.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.difficulty
old: 9.75
new: 5.428571428571429
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.vocabulary
old: 25.0
new: 22.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.length
old: 46.0
new: 42.0
path: .spaces[0].spaces[0].spaces[4].metrics.halstead.level
old: 0.10256410256410256
new: 0.18421052631578944
path: .spaces[0].spaces[0].spaces[4].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[4].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[4].metrics.mi.mi_original
old: 103.80032681728574
new: 106.2581286240772
path: .spaces[0].spaces[0].spaces[4].metrics.mi.mi_visual_studio
old: 60.70194550718464
new: 62.1392565053083
path: .spaces[0].spaces[0].spaces[4].metrics.mi.mi_sei
old: 74.25500446874803
new: 77.6990430874895
path: .spaces[0].spaces[0].spaces[4].metrics.loc.lloc
old: 3.0
new: 6.0
path: .spaces[0].spaces[0].spaces[4].metrics.loc.sloc
old: 11.0
new: 10.0
path: .spaces[0].spaces[0].spaces[4].metrics.loc.blank
old: 2.0
new: 1.0
path: .spaces[0].spaces[0].spaces[4].metrics.cyclomatic.average
old: 2.0
new: 1.0
path: .spaces[0].spaces[0].spaces[4].metrics.cyclomatic.sum
old: 2.0
new: 1.0

### Code

    void TracedTaskCommon::DoGetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);
      MOZ_ASSERT(!mIsTraceInfoInit);

      mSourceEventType = info->mCurTraceSourceType;
      mSourceEventId = info->mCurTraceSourceId;
      mTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

## Minimal test - lines (73, 80)

path: .spaces[0].spaces[0].spaces[6].metrics.mi.mi_original
old: 125.52845422402903
new: 111.42476518092914
path: .spaces[0].spaces[0].spaces[6].metrics.mi.mi_visual_studio
old: 73.40845276259009
new: 65.16068139235622
path: .spaces[0].spaces[0].spaces[6].metrics.mi.mi_sei
old: 105.50024626685564
new: 85.1529240261354
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.n1
old: 8.0
new: 7.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.difficulty
old: 5.333333333333333
new: 5.25
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.effort
old: 426.4237512704517
new: 729.6121171631855
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.N2
old: 8.0
new: 15.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.N1
old: 13.0
new: 19.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.estimated_program_length
old: 39.50977500432694
new: 52.87076540327685
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.length
old: 21.0
new: 34.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.time
old: 23.690208403913985
new: 40.53400650906586
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.level
old: 0.1875
new: 0.1904761904761905
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.n2
old: 6.0
new: 10.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.purity_ratio
old: 1.881417857348902
new: 1.555022511861084
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.vocabulary
old: 14.0
new: 17.0
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.bugs
old: 0.018884536768029512
new: 0.027015111889696748
path: .spaces[0].spaces[0].spaces[6].metrics.halstead.volume
old: 79.9544533632097
new: 138.97373660251154
path: .spaces[0].spaces[0].spaces[6].metrics.loc.ploc
old: 4.0
new: 7.0
path: .spaces[0].spaces[0].spaces[6].metrics.loc.sloc
old: 4.0
new: 8.0
path: .spaces[0].spaces[0].spaces[6].metrics.loc.blank
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].spaces[6].metrics.loc.lloc
old: 1.0
new: 4.0
path: .spaces[0].spaces[0].spaces[6].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[6].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[6].metrics.nargs.sum
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[6].metrics.nargs.average
old: 2.0
new: 0.0

### Code

    void TracedTaskCommon::ClearTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      info->mCurTraceSourceId = 0;
      info->mCurTraceSourceType = SourceEventType::Unknown;
      info->mCurTaskId = 0;
    }

## Minimal test - lines (46, 49)

path: .spaces[0].spaces[0].spaces[3].metrics.nargs.average
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].spaces[3].metrics.nargs.sum
old: 4.0
new: 1.0
path: .spaces[0].spaces[0].spaces[3].metrics.nexits.average
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.nexits.sum
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.loc.lloc
old: 12.0
new: 1.0
path: .spaces[0].spaces[0].spaces[3].metrics.loc.ploc
old: 27.0
new: 4.0
path: .spaces[0].spaces[0].spaces[3].metrics.loc.sloc
old: 33.0
new: 4.0
path: .spaces[0].spaces[0].spaces[3].metrics.loc.blank
old: 5.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.loc.cloc
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.cyclomatic.average
old: 3.0
new: 1.0
path: .spaces[0].spaces[0].spaces[3].metrics.cyclomatic.sum
old: 3.0
new: 1.0
path: .spaces[0].spaces[0].spaces[3].metrics.mi.mi_original
old: 78.48309307682716
new: 126.19700005047748
path: .spaces[0].spaces[0].spaces[3].metrics.mi.mi_sei
old: 51.15292492798336
new: 106.4647540152798
path: .spaces[0].spaces[0].spaces[3].metrics.mi.mi_visual_studio
old: 45.896545658963255
new: 73.79941523419735
path: .spaces[0].spaces[0].spaces[3].metrics.cognitive.sum
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.cognitive.average
old: 2.0
new: 0.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.effort
old: 14438.385195441808
new: 241.0572159246197
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.length
old: 153.0
new: 19.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.estimated_program_length
old: 241.52365596479055
new: 35.161259458730164
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.volume
old: 867.8810773216387
new: 70.30835464468075
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.n1
old: 18.0
new: 6.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.time
old: 802.1325108578782
new: 13.39206755136776
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.n2
old: 33.0
new: 7.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.N1
old: 92.0
new: 11.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.purity_ratio
old: 1.5785859866979777
new: 1.850592603091061
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.level
old: 0.060109289617486336
new: 0.2916666666666667
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.difficulty
old: 16.636363636363637
new: 3.4285714285714284
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.vocabulary
old: 51.0
new: 13.0
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.bugs
old: 0.1976474252970016
new: 0.012910968936152529
path: .spaces[0].spaces[0].spaces[3].metrics.halstead.N2
old: 61.0
new: 8.0

### Code

    void TracedTaskCommon::DispatchTask(int aDelayTimeMs) {
      LogDispatch(mTaskId, mParentTaskId, mSourceEventId, mSourceEventType,
                  aDelayTimeMs);
    }

## Minimal test - lines (20, 127)

path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 11.0
new: 17.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 1.375
new: 1.2142857142857142
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 9.0
new: 4.0
path: .spaces[0].spaces[0].metrics.nargs.average
old: 1.2857142857142858
new: 0.3076923076923077
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 60.0
new: 77.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 19.0
new: 34.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 78.0
new: 108.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 16.0
new: 22.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 2.0
new: 9.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 7.0
new: 13.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 7.0
new: 13.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 0.5714285714285714
new: 0.15384615384615383
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 4.0
new: 2.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 0.42857142857142855
new: 0.07692307692307693
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 3.0
new: 1.0
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 34.32772059145679
new: 29.83049323065105
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 58.70040221139111
new: 51.0101434244133
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 22.382594834598997
new: 21.24490851899245
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.4519805626425742
new: 0.5246944659079574
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 26.62
new: 27.26851851851852
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 183.0
new: 215.0
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 121.0
new: 155.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 22.0
new: 19.0
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 72.0
new: 73.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.2509878457195944
new: 1.0580393185736632
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.037565740045078885
new: 0.0366723259762309
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 49929.994675671885
new: 62451.317875774184
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 380.3003050987567
new: 391.4745478722554
path: .spaces[0].spaces[0].metrics.halstead.length
old: 304.0
new: 370.0
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 50.0
new: 54.0
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 1875.657200438463
new: 2290.2350867856067
path: .spaces[0].spaces[0].metrics.halstead.time
old: 2773.8885930928827
new: 3469.517659765233

### Code

    namespace tasktracer {

    TracedTaskCommon::TracedTaskCommon()
        : mSourceEventType(SourceEventType::Unknown),
          mSourceEventId(0),
          mParentTaskId(0),
          mTaskId(0),
          mIsTraceInfoInit(false) {}

    TracedTaskCommon::~TracedTaskCommon() {}

    void TracedTaskCommon::Init() {
      // Keep the following line before GetOrCreateTraceInfo() to avoid a
      // deadlock.
      uint64_t taskid = GenNewUniqueTaskId();

      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      mTaskId = taskid;
      mSourceEventId = info->mCurTraceSourceId;
      mSourceEventType = info->mCurTraceSourceType;
      mParentTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

    void TracedTaskCommon::DispatchTask(int aDelayTimeMs) {
      LogDispatch(mTaskId, mParentTaskId, mSourceEventId, mSourceEventType,
                  aDelayTimeMs);
    }

    void TracedTaskCommon::DoGetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);
      MOZ_ASSERT(!mIsTraceInfoInit);

      mSourceEventType = info->mCurTraceSourceType;
      mSourceEventId = info->mCurTraceSourceId;
      mTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

    void TracedTaskCommon::DoSetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      if (mIsTraceInfoInit) {
        info->mCurTraceSourceId = mSourceEventId;
        info->mCurTraceSourceType = mSourceEventType;
        info->mCurTaskId = mTaskId;
      }
    }

    void TracedTaskCommon::ClearTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      info->mCurTraceSourceId = 0;
      info->mCurTraceSourceType = SourceEventType::Unknown;
      info->mCurTaskId = 0;
    }

    /**
     * Implementation of class TracedRunnable.
     */

    NS_IMPL_ISUPPORTS(TracedRunnable, nsIRunnable);

    TracedRunnable::TracedRunnable(already_AddRefed&& aOriginalObj)
        : TracedTaskCommon(), mOriginalObj(std::move(aOriginalObj)) {
      Init();
      LogVirtualTablePtr(mTaskId, mSourceEventId,
                         *reinterpret_cast(mOriginalObj.get()));
    }

    TracedRunnable::~TracedRunnable() {}

    NS_IMETHODIMP
    TracedRunnable::Run() {
      SetTLSTraceInfo();
      LogBegin(mTaskId, mSourceEventId);
      nsresult rv = mOriginalObj->Run();
      LogEnd(mTaskId, mSourceEventId);
      ClearTLSTraceInfo();

      return rv;
    }

    /**
     * CreateTracedRunnable() returns a TracedRunnable wrapping the original
     * nsIRunnable object, aRunnable.
     */
    already_AddRefed CreateTracedRunnable(
        already_AddRefed&& aRunnable) {
      RefPtr runnable = new TracedRunnable(std::move(aRunnable));
      return runnable.forget();
    }

    void VirtualTask::AutoRunTask::StartScope(VirtualTask* aTask) {
      mTask->SetTLSTraceInfo();
      LogBegin(mTask->mTaskId, mTask->mSourceEventId);
    }

    void VirtualTask::AutoRunTask::StopScope() {
      LogEnd(mTask->mTaskId, mTask->mSourceEventId);
    }

    }  // namespace tasktracer

## Minimal test - lines (19, 128)

path: .spaces[0].metrics.halstead.n1
old: 22.0
new: 19.0
path: .spaces[0].metrics.halstead.difficulty
old: 26.77358490566038
new: 26.945454545454545
path: .spaces[0].metrics.halstead.level
old: 0.03735024665257224
new: 0.037112010796221326
path: .spaces[0].metrics.halstead.N1
old: 193.0
new: 216.0
path: .spaces[0].metrics.halstead.bugs
old: 0.4744503849523235
new: 0.5235200202935766
path: .spaces[0].metrics.halstead.volume
old: 2005.6796183396737
new: 2309.9166520139693
path: .spaces[0].metrics.halstead.n2
old: 53.0
new: 55.0
path: .spaces[0].metrics.halstead.N2
old: 129.0
new: 156.0
path: .spaces[0].metrics.halstead.effort
old: 53699.23355516975
new: 62241.75415063095
path: .spaces[0].metrics.halstead.estimated_program_length
old: 401.68727970187007
new: 398.6854069992844
path: .spaces[0].metrics.halstead.length
old: 322.0
new: 372.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.2474760239188512
new: 1.0717349650518395
path: .spaces[0].metrics.halstead.vocabulary
old: 75.0
new: 74.0
path: .spaces[0].metrics.halstead.time
old: 2983.290753064986
new: 3457.875230590608
path: .spaces[0].metrics.cognitive.sum
old: 3.0
new: 1.0
path: .spaces[0].metrics.cognitive.average
old: 0.42857142857142855
new: 0.07692307692307693
path: .spaces[0].metrics.loc.ploc
old: 66.0
new: 79.0
path: .spaces[0].metrics.loc.blank
old: 18.0
new: 21.0
path: .spaces[0].metrics.loc.lloc
old: 19.0
new: 34.0
path: .spaces[0].metrics.loc.cloc
old: 2.0
new: 10.0
path: .spaces[0].metrics.loc.sloc
old: 86.0
new: 110.0
path: .spaces[0].metrics.nargs.average
old: 1.2857142857142858
new: 0.3076923076923077
path: .spaces[0].metrics.nargs.sum
old: 9.0
new: 4.0
path: .spaces[0].metrics.nom.functions
old: 7.0
new: 13.0
path: .spaces[0].metrics.nom.total
old: 7.0
new: 13.0
path: .spaces[0].metrics.cyclomatic.sum
old: 12.0
new: 18.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.3333333333333333
new: 1.2
path: .spaces[0].metrics.mi.mi_original
old: 56.54013493152124
new: 50.43839112243742
path: .spaces[0].metrics.mi.mi_visual_studio
old: 33.06440639270247
new: 29.496135159320133
path: .spaces[0].metrics.mi.mi_sei
old: 18.794069693239436
new: 21.414035767070025
path: .spaces[0].metrics.nexits.sum
old: 4.0
new: 2.0
path: .spaces[0].metrics.nexits.average
old: 0.5714285714285714
new: 0.15384615384615383

### Code

    namespace mozilla {
    namespace tasktracer {

    TracedTaskCommon::TracedTaskCommon()
        : mSourceEventType(SourceEventType::Unknown),
          mSourceEventId(0),
          mParentTaskId(0),
          mTaskId(0),
          mIsTraceInfoInit(false) {}

    TracedTaskCommon::~TracedTaskCommon() {}

    void TracedTaskCommon::Init() {
      // Keep the following line before GetOrCreateTraceInfo() to avoid a
      // deadlock.
      uint64_t taskid = GenNewUniqueTaskId();

      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      mTaskId = taskid;
      mSourceEventId = info->mCurTraceSourceId;
      mSourceEventType = info->mCurTraceSourceType;
      mParentTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

    void TracedTaskCommon::DispatchTask(int aDelayTimeMs) {
      LogDispatch(mTaskId, mParentTaskId, mSourceEventId, mSourceEventType,
                  aDelayTimeMs);
    }

    void TracedTaskCommon::DoGetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);
      MOZ_ASSERT(!mIsTraceInfoInit);

      mSourceEventType = info->mCurTraceSourceType;
      mSourceEventId = info->mCurTraceSourceId;
      mTaskId = info->mCurTaskId;
      mIsTraceInfoInit = true;
    }

    void TracedTaskCommon::DoSetTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      if (mIsTraceInfoInit) {
        info->mCurTraceSourceId = mSourceEventId;
        info->mCurTraceSourceType = mSourceEventType;
        info->mCurTaskId = mTaskId;
      }
    }

    void TracedTaskCommon::ClearTLSTraceInfo() {
      TraceInfoHolder info = GetOrCreateTraceInfo();
      ENSURE_TRUE_VOID(info);

      info->mCurTraceSourceId = 0;
      info->mCurTraceSourceType = SourceEventType::Unknown;
      info->mCurTaskId = 0;
    }

    /**
     * Implementation of class TracedRunnable.
     */

    NS_IMPL_ISUPPORTS(TracedRunnable, nsIRunnable);

    TracedRunnable::TracedRunnable(already_AddRefed&& aOriginalObj)
        : TracedTaskCommon(), mOriginalObj(std::move(aOriginalObj)) {
      Init();
      LogVirtualTablePtr(mTaskId, mSourceEventId,
                         *reinterpret_cast(mOriginalObj.get()));
    }

    TracedRunnable::~TracedRunnable() {}

    NS_IMETHODIMP
    TracedRunnable::Run() {
      SetTLSTraceInfo();
      LogBegin(mTaskId, mSourceEventId);
      nsresult rv = mOriginalObj->Run();
      LogEnd(mTaskId, mSourceEventId);
      ClearTLSTraceInfo();

      return rv;
    }

    /**
     * CreateTracedRunnable() returns a TracedRunnable wrapping the original
     * nsIRunnable object, aRunnable.
     */
    already_AddRefed CreateTracedRunnable(
        already_AddRefed&& aRunnable) {
      RefPtr runnable = new TracedRunnable(std::move(aRunnable));
      return runnable.forget();
    }

    void VirtualTask::AutoRunTask::StartScope(VirtualTask* aTask) {
      mTask->SetTLSTraceInfo();
      LogBegin(mTask->mTaskId, mTask->mSourceEventId);
    }

    void VirtualTask::AutoRunTask::StopScope() {
      LogEnd(mTask->mTaskId, mTask->mSourceEventId);
    }

    }  // namespace tasktracer
    }  // namespace mozilla