Global Metrics
path: .metrics.halstead.N1
old: 1502.0
new: 584.0
path: .metrics.halstead.difficulty
old: 110.5868263473054
new: 18.36322869955157
path: .metrics.halstead.n1
old: 38.0
new: 21.0
path: .metrics.halstead.bugs
old: 5.468086190524628
new: 0.9066224234017214
path: .metrics.halstead.N2
old: 972.0
new: 390.0
path: .metrics.halstead.time
old: 116724.60265926384
new: 7880.414497506155
path: .metrics.halstead.purity_ratio
old: 0.5790217713637925
new: 1.880738545750084
path: .metrics.halstead.level
old: 0.009042668399393546
new: 0.05445665445665446
path: .metrics.halstead.volume
old: 18999.033766176475
new: 7724.538166786252
path: .metrics.halstead.vocabulary
old: 205.0
new: 244.0
path: .metrics.halstead.effort
old: 2101042.8478667494
new: 141847.4609551108
path: .metrics.halstead.estimated_program_length
old: 1432.4998623540228
new: 1831.839343560582
path: .metrics.halstead.n2
old: 167.0
new: 223.0
path: .metrics.halstead.length
old: 2474.0
new: 974.0
path: .metrics.cognitive.average
old: 5.545454545454546
new: 0.037037037037037035
path: .metrics.cognitive.sum
old: 122.0
new: 1.0
path: .metrics.nargs.average
old: 0.6818181818181818
new: 0.6666666666666666
path: .metrics.nargs.sum
old: 15.0
new: 18.0
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 7.37652877051614
path: .metrics.mi.mi_original
old: -8.246500899882548
new: 12.6138641975826
path: .metrics.mi.mi_sei
old: -50.6237926795084
new: -19.12164573097601
path: .metrics.nexits.average
old: 1.7272727272727273
new: 0.5185185185185185
path: .metrics.nexits.sum
old: 38.0
new: 14.0
path: .metrics.nom.functions
old: 22.0
new: 27.0
path: .metrics.nom.total
old: 22.0
new: 27.0
path: .metrics.cyclomatic.average
old: 4.615384615384615
new: 1.183673469387755
path: .metrics.cyclomatic.sum
old: 120.0
new: 58.0
path: .metrics.loc.sloc
old: 492.0
new: 437.0
path: .metrics.loc.ploc
old: 389.0
new: 254.0
path: .metrics.loc.cloc
old: 55.0
new: 91.0
path: .metrics.loc.blank
old: 48.0
new: 92.0
path: .metrics.loc.lloc
old: 163.0
new: 21.0
Spaces Data
Minimal test - lines (33, 33)
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 1.1
new: 1.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 11.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 0.1111111111111111
new: null
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 0.7777777777777778
new: null
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 7.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 9.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 9.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 143.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.03110047846889952
new: null
path: .spaces[0].spaces[0].metrics.halstead.time
old: 2184.8659711154532
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 39327.58748007816
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 220.31892828168893
new: null
path: .spaces[0].spaces[0].metrics.halstead.length
old: 219.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 32.15384615384615
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 26.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 48.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.3854874844539285
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 76.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 22.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.0060225035693555
new: null
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 1223.1067876579332
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 15.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 29.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 4.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 3.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 22.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nargs.average
old: 0.4444444444444444
new: null
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 60.3332243373054
new: null
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 76.9522304244598
new: null
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 45.00130434178936
new: null
Code
class CycleCollectedJSContext;
Minimal test - lines (32, 40)
path: .spaces[0].metrics.loc.lloc
old: 15.0
new: 0.0
path: .spaces[0].metrics.loc.sloc
old: 42.0
new: 9.0
path: .spaces[0].metrics.loc.ploc
old: 28.0
new: 8.0
path: .spaces[0].metrics.loc.blank
old: 6.0
new: 1.0
path: .spaces[0].metrics.loc.cloc
old: 8.0
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[0].metrics.nargs.average
old: 0.4444444444444444
new: null
path: .spaces[0].metrics.halstead.level
old: 0.03176341730558598
new: 0.3333333333333333
path: .spaces[0].metrics.halstead.vocabulary
old: 51.0
new: 14.0
path: .spaces[0].metrics.halstead.bugs
old: 0.4036898153241196
new: 0.011611549046499223
path: .spaces[0].metrics.halstead.n2
old: 29.0
new: 8.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 238.9889444687201
new: 39.50977500432694
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.0126650189352546
new: 2.194987500240386
path: .spaces[0].metrics.halstead.time
old: 2341.429393838916
new: 11.422064766172811
path: .spaces[0].metrics.halstead.volume
old: 1338.6923807052729
new: 68.53238859703687
path: .spaces[0].metrics.halstead.N1
old: 153.0
new: 10.0
path: .spaces[0].metrics.halstead.N2
old: 83.0
new: 8.0
path: .spaces[0].metrics.halstead.effort
old: 42145.72908910049
new: 205.59716579111063
path: .spaces[0].metrics.halstead.difficulty
old: 31.482758620689655
new: 3.0
path: .spaces[0].metrics.halstead.n1
old: 22.0
new: 6.0
path: .spaces[0].metrics.halstead.length
old: 236.0
new: 18.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 41.0834032523398
new: 65.5222036587288
path: .spaces[0].metrics.mi.mi_original
old: 70.25261956150106
new: 112.04296825642624
path: .spaces[0].metrics.mi.mi_sei
old: 58.162790739875376
new: 86.55390183443971
path: .spaces[0].metrics.cyclomatic.average
old: 1.0909090909090908
new: 1.0
path: .spaces[0].metrics.cyclomatic.sum
old: 12.0
new: 6.0
path: .spaces[0].metrics.nom.total
old: 9.0
new: 0.0
path: .spaces[0].metrics.nom.functions
old: 9.0
new: 0.0
path: .spaces[0].metrics.nexits.sum
old: 7.0
new: 0.0
path: .spaces[0].metrics.nexits.average
old: 0.7777777777777778
new: null
path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[0].metrics.cognitive.average
old: 0.1111111111111111
new: null
Code
namespace mozilla {
class CycleCollectedJSContext;
class SynchronizedEventQueue;
class ThreadEventQueue;
class ThreadEventTarget;
template
class Array;
} // namespace mozilla
Minimal test - lines (46, 46)
path: .spaces[3].metrics.mi.mi_visual_studio
old: 48.86899213322998
new: null
path: .spaces[3].metrics.mi.mi_sei
old: 45.57210697640657
new: null
path: .spaces[3].metrics.mi.mi_original
old: 83.56597654782327
new: null
path: .spaces[3].metrics.nexits.average
old: 0.0
new: null
path: .spaces[3].metrics.cyclomatic.average
old: 7.0
new: 1.0
path: .spaces[3].metrics.cyclomatic.sum
old: 7.0
new: 1.0
path: .spaces[3].metrics.loc.lloc
old: 13.0
new: 0.0
path: .spaces[3].metrics.loc.sloc
old: 28.0
new: 1.0
path: .spaces[3].metrics.loc.ploc
old: 28.0
new: 1.0
path: .spaces[3].metrics.nargs.average
old: 0.0
new: null
path: .spaces[3].metrics.cognitive.average
old: 14.0
new: null
path: .spaces[3].metrics.cognitive.sum
old: 14.0
new: 0.0
path: .spaces[3].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[3].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[3].metrics.halstead.bugs
old: 0.1545675913368859
new: 0.0
path: .spaces[3].metrics.halstead.vocabulary
old: 27.0
new: 1.0
path: .spaces[3].metrics.halstead.n1
old: 15.0
new: 0.0
path: .spaces[3].metrics.halstead.effort
old: 9985.263754543284
new: 0.0
path: .spaces[3].metrics.halstead.N2
old: 35.0
new: 1.0
path: .spaces[3].metrics.halstead.volume
old: 456.46920020769295
new: 0.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 101.62290894278166
new: null
path: .spaces[3].metrics.halstead.difficulty
old: 21.875
new: 0.0
path: .spaces[3].metrics.halstead.length
old: 96.0
new: 1.0
path: .spaces[3].metrics.halstead.level
old: 0.045714285714285714
new: null
path: .spaces[3].metrics.halstead.time
old: 554.7368752524046
new: 0.0
path: .spaces[3].metrics.halstead.n2
old: 12.0
new: 1.0
path: .spaces[3].metrics.halstead.N1
old: 61.0
new: 0.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.0585719681539756
new: null
Code
class nsThreadEnumerator;
Minimal test - lines (381, 397)
path: .spaces[7].metrics.halstead.purity_ratio
old: 2.0294069451656003
new: 1.6324952803335864
path: .spaces[7].metrics.halstead.bugs
old: 0.017323846317002522
new: 0.0728653313804455
path: .spaces[7].metrics.halstead.difficulty
old: 5.625
new: 13.3
path: .spaces[7].metrics.halstead.estimated_program_length
old: 36.529325012980806
new: 86.52224985768008
path: .spaces[7].metrics.halstead.vocabulary
old: 13.0
new: 24.0
path: .spaces[7].metrics.halstead.level
old: 0.17777777777777778
new: 0.07518796992481203
path: .spaces[7].metrics.halstead.N1
old: 13.0
new: 34.0
path: .spaces[7].metrics.halstead.effort
old: 374.6695214617856
new: 3231.940066758343
path: .spaces[7].metrics.halstead.n1
old: 9.0
new: 14.0
path: .spaces[7].metrics.halstead.n2
old: 4.0
new: 10.0
path: .spaces[7].metrics.halstead.length
old: 18.0
new: 53.0
path: .spaces[7].metrics.halstead.time
old: 20.814973414543644
new: 179.55222593101905
path: .spaces[7].metrics.halstead.N2
old: 5.0
new: 19.0
path: .spaces[7].metrics.halstead.volume
old: 66.60791492653966
new: 243.00301253822127
path: .spaces[7].metrics.nom.total
old: 1.0
new: 3.0
path: .spaces[7].metrics.nom.functions
old: 1.0
new: 3.0
path: .spaces[7].metrics.loc.ploc
old: 5.0
new: 15.0
path: .spaces[7].metrics.loc.sloc
old: 5.0
new: 17.0
path: .spaces[7].metrics.loc.blank
old: 0.0
new: 2.0
path: .spaces[7].metrics.nargs.average
old: 0.0
new: 0.6666666666666666
path: .spaces[7].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[7].metrics.mi.mi_visual_studio
old: 71.71533571332904
new: 55.64792974004653
path: .spaces[7].metrics.mi.mi_original
old: 122.63322406979267
new: 95.15795985547956
path: .spaces[7].metrics.mi.mi_sei
old: 101.42513194051114
new: 62.193983949025466
path: .spaces[7].metrics.nexits.average
old: 1.0
new: 0.3333333333333333
path: .spaces[7].metrics.cyclomatic.sum
old: 2.0
new: 6.0
path: .spaces[7].metrics.cyclomatic.average
old: 2.0
new: 1.5
Code
class MOZ_RAII nsLocalExecutionGuard final {
public:
MOZ_IMPLICIT nsLocalExecutionGuard(
nsLocalExecutionRecord&& aLocalExecutionRecord);
nsLocalExecutionGuard(const nsLocalExecutionGuard&) = delete;
nsLocalExecutionGuard(nsLocalExecutionGuard&&) = delete;
~nsLocalExecutionGuard();
nsCOMPtr GetEventTarget() const {
return mLocalEventTarget;
}
private:
mozilla::SynchronizedEventQueue& mEventQueueStack;
nsCOMPtr mLocalEventTarget;
bool& mLocalExecutionFlag;
};
Minimal test - lines (419, 428)
path: .spaces[9].metrics.nom.functions
old: 1.0
new: 3.0
path: .spaces[9].metrics.nom.total
old: 1.0
new: 3.0
path: .spaces[9].metrics.cyclomatic.sum
old: 1.0
new: 4.0
path: .spaces[9].metrics.nexits.average
old: 1.0
new: 0.6666666666666666
path: .spaces[9].metrics.nexits.sum
old: 1.0
new: 2.0
path: .spaces[9].metrics.mi.mi_sei
old: 106.5105871671506
new: 78.38067332474107
path: .spaces[9].metrics.mi.mi_visual_studio
old: 73.81799366694318
new: 62.29173699169525
path: .spaces[9].metrics.mi.mi_original
old: 126.22876917047284
new: 106.51887025579887
path: .spaces[9].metrics.halstead.estimated_program_length
old: 21.651484454403228
new: 48.18080946738404
path: .spaces[9].metrics.halstead.time
old: 6.780117364196057
new: 61.285714285714285
path: .spaces[9].metrics.halstead.effort
old: 122.04211255552904
new: 1103.142857142857
path: .spaces[9].metrics.halstead.volume
old: 34.86917501586544
new: 156.0
path: .spaces[9].metrics.halstead.bugs
old: 0.008201347674923783
new: 0.03558769966684976
path: .spaces[9].metrics.halstead.length
old: 11.0
new: 39.0
path: .spaces[9].metrics.halstead.vocabulary
old: 9.0
new: 16.0
path: .spaces[9].metrics.halstead.N1
old: 9.0
new: 28.0
path: .spaces[9].metrics.halstead.n2
old: 2.0
new: 7.0
path: .spaces[9].metrics.halstead.difficulty
old: 3.5
new: 7.071428571428571
path: .spaces[9].metrics.halstead.N2
old: 2.0
new: 11.0
path: .spaces[9].metrics.halstead.purity_ratio
old: 1.9683167685821117
new: 1.235405370958565
path: .spaces[9].metrics.halstead.n1
old: 7.0
new: 9.0
path: .spaces[9].metrics.halstead.level
old: 0.2857142857142857
new: 0.1414141414141414
path: .spaces[9].metrics.loc.blank
old: 0.0
new: 2.0
path: .spaces[9].metrics.loc.sloc
old: 5.0
new: 10.0
path: .spaces[9].metrics.loc.ploc
old: 5.0
new: 8.0
path: .spaces[9].metrics.loc.lloc
old: 1.0
new: 2.0
Code
class MOZ_STACK_CLASS nsThreadEnumerator final {
public:
nsThreadEnumerator() = default;
auto begin() { return nsThread::ThreadList().begin(); }
auto end() { return nsThread::ThreadList().end(); }
private:
mozilla::OffTheBooksMutexAutoLock mMal{nsThread::ThreadListMutex()};
};
Minimal test - lines (356, 365)
path: .spaces[6].metrics.loc.sloc
old: 5.0
new: 10.0
path: .spaces[6].metrics.loc.ploc
old: 5.0
new: 10.0
path: .spaces[6].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[6].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[6].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[6].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[6].metrics.cyclomatic.average
old: 4.0
new: 1.0
path: .spaces[6].metrics.cyclomatic.sum
old: 4.0
new: 1.0
path: .spaces[6].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[6].metrics.nargs.average
old: 0.0
new: 3.0
path: .spaces[6].metrics.mi.mi_sei
old: 98.3996514058146
new: 76.64697117511061
path: .spaces[6].metrics.mi.mi_visual_studio
old: 70.40641431016748
new: 61.7127999674067
path: .spaces[6].metrics.mi.mi_original
old: 120.39496847038636
new: 105.52888794426546
path: .spaces[6].metrics.halstead.N1
old: 19.0
new: 26.0
path: .spaces[6].metrics.halstead.n2
old: 5.0
new: 14.0
path: .spaces[6].metrics.halstead.time
old: 26.04593730405679
new: 89.78884897245597
path: .spaces[6].metrics.halstead.volume
old: 93.76537429460444
new: 215.49323753389433
path: .spaces[6].metrics.halstead.difficulty
old: 5.0
new: 7.5
path: .spaces[6].metrics.halstead.estimated_program_length
old: 44.82892142331043
new: 86.52224985768008
path: .spaces[6].metrics.halstead.length
old: 24.0
new: 47.0
path: .spaces[6].metrics.halstead.purity_ratio
old: 1.867871725971268
new: 1.8408989331421293
path: .spaces[6].metrics.halstead.level
old: 0.2
new: 0.13333333333333333
path: .spaces[6].metrics.halstead.bugs
old: 0.020116561188551544
new: 0.045906623561399594
path: .spaces[6].metrics.halstead.effort
old: 468.8268714730222
new: 1616.1992815042074
path: .spaces[6].metrics.halstead.vocabulary
old: 15.0
new: 24.0
path: .spaces[6].metrics.halstead.N2
old: 5.0
new: 21.0
Code
nsThreadShutdownContext(NotNull aTerminatingThread,
NotNull aJoiningThread,
bool aAwaitingShutdownAck)
: mTerminatingThread(aTerminatingThread),
mTerminatingPRThread(aTerminatingThread->GetPRThread()),
mJoiningThread(aJoiningThread),
mAwaitingShutdownAck(aAwaitingShutdownAck),
mIsMainThreadJoining(NS_IsMainThread()) {
MOZ_COUNT_CTOR(nsThreadShutdownContext);
}
Minimal test - lines (44, 44)
path: .spaces[1].metrics.halstead.estimated_program_length
old: 174.1007298075732
new: null
path: .spaces[1].metrics.halstead.length
old: 102.0
new: 1.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.706869900074247
new: null
path: .spaces[1].metrics.halstead.effort
old: 3253.2561933341767
new: 0.0
path: .spaces[1].metrics.halstead.n2
old: 29.0
new: 1.0
path: .spaces[1].metrics.halstead.N2
old: 35.0
new: 1.0
path: .spaces[1].metrics.halstead.level
old: 0.16571428571428573
new: null
path: .spaces[1].metrics.halstead.n1
old: 10.0
new: 0.0
path: .spaces[1].metrics.halstead.volume
old: 539.1110263239493
new: 0.0
path: .spaces[1].metrics.halstead.N1
old: 67.0
new: 0.0
path: .spaces[1].metrics.halstead.difficulty
old: 6.0344827586206895
new: 0.0
path: .spaces[1].metrics.halstead.time
old: 180.73645518523205
new: 0.0
path: .spaces[1].metrics.halstead.bugs
old: 0.0731853670718304
new: 0.0
path: .spaces[1].metrics.halstead.vocabulary
old: 39.0
new: 1.0
path: .spaces[1].metrics.mi.mi_visual_studio
old: 48.516380370002445
new: null
path: .spaces[1].metrics.mi.mi_sei
old: 67.61808371481831
new: null
path: .spaces[1].metrics.mi.mi_original
old: 82.96301043270418
new: null
path: .spaces[1].metrics.loc.sloc
old: 30.0
new: 1.0
path: .spaces[1].metrics.loc.cloc
old: 3.0
new: 0.0
path: .spaces[1].metrics.loc.blank
old: 1.0
new: 0.0
path: .spaces[1].metrics.loc.ploc
old: 26.0
new: 1.0
Code
class nsIRunnable;
Minimal test - lines (52, 150)
path: .spaces[4].metrics.cognitive.sum
old: 12.0
new: 0.0
path: .spaces[4].metrics.cognitive.average
old: 12.0
new: 0.0
path: .spaces[4].metrics.halstead.N1
old: 87.0
new: 108.0
path: .spaces[4].metrics.halstead.estimated_program_length
old: 173.52879329056708
new: 244.720658986051
path: .spaces[4].metrics.halstead.volume
old: 734.426077094456
new: 1026.7089868968403
path: .spaces[4].metrics.halstead.n1
old: 23.0
new: 15.0
path: .spaces[4].metrics.halstead.N2
old: 51.0
new: 73.0
path: .spaces[4].metrics.halstead.difficulty
old: 34.5
new: 15.208333333333334
path: .spaces[4].metrics.halstead.time
old: 1407.6499810977073
new: 867.4740282808954
path: .spaces[4].metrics.halstead.n2
old: 17.0
new: 36.0
path: .spaces[4].metrics.halstead.bugs
old: 0.2875567288441201
new: 0.2082402785775889
path: .spaces[4].metrics.halstead.length
old: 138.0
new: 181.0
path: .spaces[4].metrics.halstead.effort
old: 25337.69965975873
new: 15614.532509056116
path: .spaces[4].metrics.halstead.level
old: 0.028985507246376812
new: 0.06575342465753424
path: .spaces[4].metrics.halstead.vocabulary
old: 40.0
new: 51.0
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.2574550238446889
new: 1.352047839701939
path: .spaces[4].metrics.cyclomatic.average
old: 8.0
new: 1.2
path: .spaces[4].metrics.cyclomatic.sum
old: 8.0
new: 12.0
path: .spaces[4].metrics.nexits.average
old: 3.0
new: 0.42857142857142855
path: .spaces[4].metrics.nom.total
old: 1.0
new: 7.0
path: .spaces[4].metrics.nom.functions
old: 1.0
new: 7.0
path: .spaces[4].metrics.mi.mi_sei
old: 57.31161348961218
new: 49.41042004519289
path: .spaces[4].metrics.mi.mi_visual_studio
old: 47.63285272975375
new: 33.76705650822349
path: .spaces[4].metrics.mi.mi_original
old: 81.45217816787891
new: 57.741666629062166
path: .spaces[4].metrics.loc.sloc
old: 27.0
new: 99.0
path: .spaces[4].metrics.loc.blank
old: 0.0
new: 16.0
path: .spaces[4].metrics.loc.lloc
old: 14.0
new: 3.0
path: .spaces[4].metrics.loc.cloc
old: 1.0
new: 37.0
path: .spaces[4].metrics.loc.ploc
old: 27.0
new: 46.0
path: .spaces[4].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[4].metrics.nargs.sum
old: 0.0
new: 7.0
Code
namespace mozilla {
class PerformanceCounterState {
public:
explicit PerformanceCounterState(const uint32_t& aNestedEventLoopDepthRef,
bool aIsMainThread)
: mNestedEventLoopDepth(aNestedEventLoopDepthRef),
mIsMainThread(aIsMainThread),
// Does it really make sense to initialize these to "now" when we
// haven't run any tasks?
mLastLongTaskEnd(TimeStamp::Now()),
mLastLongNonIdleTaskEnd(mLastLongTaskEnd) {}
class Snapshot {
public:
Snapshot(uint32_t aOldEventLoopDepth, PerformanceCounter* aCounter,
bool aOldIsIdleRunnable)
: mOldEventLoopDepth(aOldEventLoopDepth),
mOldPerformanceCounter(aCounter),
mOldIsIdleRunnable(aOldIsIdleRunnable) {}
Snapshot(const Snapshot&) = default;
Snapshot(Snapshot&&) = default;
private:
friend class PerformanceCounterState;
const uint32_t mOldEventLoopDepth;
// Non-const so we can move out of it and avoid the extra refcounting.
RefPtr mOldPerformanceCounter;
const bool mOldIsIdleRunnable;
};
// Notification that a runnable is about to run. This captures a snapshot of
// our current state before we reset to prepare for the new runnable. This
// muast be called after mNestedEventLoopDepth has been incremented for the
// runnable execution. The performance counter passed in should be the one
// for the relevant runnable and may be null. aIsIdleRunnable should be true
// if and only if the runnable has idle priority.
Snapshot RunnableWillRun(PerformanceCounter* Counter, TimeStamp aNow,
bool aIsIdleRunnable);
// Notification that a runnable finished executing. This must be passed the
// snapshot that RunnableWillRun returned for the same runnable. This must be
// called before mNestedEventLoopDepth is decremented after the runnable's
// execution.
void RunnableDidRun(Snapshot&& aSnapshot);
const TimeStamp& LastLongTaskEnd() const { return mLastLongTaskEnd; }
const TimeStamp& LastLongNonIdleTaskEnd() const {
return mLastLongNonIdleTaskEnd;
}
private:
// Called to report accumulated time, as needed, when we're about to run a
// runnable or just finished running one.
void MaybeReportAccumulatedTime(TimeStamp aNow);
// Whether the runnable we are about to run, or just ran, is a nested
// runnable, in the sense that there is some other runnable up the stack
// spinning the event loop. This must be called before we change our
// mCurrentEventLoopDepth (when about to run a new event) or after we restore
// it (after we ran one).
bool IsNestedRunnable() const {
return mNestedEventLoopDepth > mCurrentEventLoopDepth;
}
// The event loop depth of the currently running runnable. Set to the max
// value of a uint32_t when there is no runnable running, so when starting to
// run a toplevel (not nested) runnable IsNestedRunnable() will test false.
uint32_t mCurrentEventLoopDepth = std::numeric_limits::max();
// A reference to the nsThread's mNestedEventLoopDepth, so we can
// see what it is right now.
const uint32_t& mNestedEventLoopDepth;
// A boolean that indicates whether the currently running runnable is an idle
// runnable. Only has a useful value between RunnableWillRun() being called
// and RunnableDidRun() returning.
bool mCurrentRunnableIsIdleRunnable = false;
// Whether we're attached to the mainthread nsThread.
const bool mIsMainThread;
// The timestamp from which time to be accounted for should be measured. This
// can be the start of a runnable running or the end of a nested runnable
// running.
TimeStamp mCurrentTimeSliceStart;
// Information about when long tasks last ended.
TimeStamp mLastLongTaskEnd;
TimeStamp mLastLongNonIdleTaskEnd;
// The performance counter to use for accumulating the runtime of
// the currently running event. May be null, in which case the
// event's running time should not be accounted to any performance
// counters.
RefPtr mCurrentPerformanceCounter;
};
} // namespace mozilla
Minimal test - lines (153, 353)
path: .spaces[5].metrics.loc.lloc
old: 26.0
new: 12.0
path: .spaces[5].metrics.loc.ploc
old: 61.0
new: 108.0
path: .spaces[5].metrics.loc.cloc
old: 7.0
new: 38.0
path: .spaces[5].metrics.loc.sloc
old: 71.0
new: 201.0
path: .spaces[5].metrics.loc.blank
old: 3.0
new: 55.0
path: .spaces[5].metrics.cyclomatic.sum
old: 21.0
new: 16.0
path: .spaces[5].metrics.cyclomatic.average
old: 21.0
new: 1.0
path: .spaces[5].metrics.nexits.average
old: 6.0
new: 0.8
path: .spaces[5].metrics.nexits.sum
old: 6.0
new: 8.0
path: .spaces[5].metrics.nargs.average
old: 1.0
new: 0.2
path: .spaces[5].metrics.nargs.sum
old: 1.0
new: 2.0
path: .spaces[5].metrics.nom.functions
old: 1.0
new: 10.0
path: .spaces[5].metrics.nom.total
old: 1.0
new: 10.0
path: .spaces[5].metrics.cognitive.average
old: 12.0
new: 0.0
path: .spaces[5].metrics.cognitive.sum
old: 12.0
new: 0.0
path: .spaces[5].metrics.halstead.estimated_program_length
old: 412.51927008770485
new: 1019.3701056018622
path: .spaces[5].metrics.halstead.volume
old: 2412.712818167537
new: 3575.7719412265888
path: .spaces[5].metrics.halstead.vocabulary
old: 77.0
new: 151.0
path: .spaces[5].metrics.halstead.bugs
old: 0.6457015600826843
new: 0.39156016216977824
path: .spaces[5].metrics.halstead.level
old: 0.028299319727891157
new: 0.08881578947368421
path: .spaces[5].metrics.halstead.length
old: 385.0
new: 494.0
path: .spaces[5].metrics.halstead.effort
old: 85256.91929582402
new: 40260.54333825492
path: .spaces[5].metrics.halstead.N1
old: 238.0
new: 304.0
path: .spaces[5].metrics.halstead.N2
old: 147.0
new: 190.0
path: .spaces[5].metrics.halstead.n1
old: 25.0
new: 16.0
path: .spaces[5].metrics.halstead.purity_ratio
old: 1.0714786236044282
new: 2.0635022380604497
path: .spaces[5].metrics.halstead.n2
old: 52.0
new: 135.0
path: .spaces[5].metrics.halstead.difficulty
old: 35.33653846153846
new: 11.25925925925926
path: .spaces[5].metrics.halstead.time
old: 4736.4955164346675
new: 2236.6968521252734
path: .spaces[5].metrics.mi.mi_sei
old: 31.488507717288112
new: 13.181982567046989
path: .spaces[5].metrics.mi.mi_visual_studio
old: 33.10780664478053
new: 22.725375099638217
path: .spaces[5].metrics.mi.mi_original
old: 56.614349362574714
new: 38.86039142038135
Code
class nsThread : public nsIThreadInternal,
public nsISupportsPriority,
public nsIDirectTaskDispatcher,
private mozilla::LinkedListElement {
friend mozilla::LinkedList;
friend mozilla::LinkedListElement;
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIEVENTTARGET_FULL
NS_DECL_NSITHREAD
NS_DECL_NSITHREADINTERNAL
NS_DECL_NSISUPPORTSPRIORITY
NS_DECL_NSIDIRECTTASKDISPATCHER
enum MainThreadFlag { MAIN_THREAD, NOT_MAIN_THREAD };
nsThread(NotNull aQueue,
MainThreadFlag aMainThread, uint32_t aStackSize);
private:
nsThread();
public:
// Initialize this as a named wrapper for a new PRThread.
nsresult Init(const nsACString& aName);
// Initialize this as a wrapper for the current PRThread.
nsresult InitCurrentThread();
private:
// Initializes the mThreadId and stack base/size members, and adds the thread
// to the ThreadList().
void InitCommon();
public:
// The PRThread corresponding to this thread.
PRThread* GetPRThread() const { return mThread; }
const void* StackBase() const { return mStackBase; }
size_t StackSize() const { return mStackSize; }
uint32_t ThreadId() const { return mThreadId; }
// If this flag is true, then the nsThread was created using
// nsIThreadManager::NewThread.
bool ShutdownRequired() { return mShutdownRequired; }
// Lets GetRunningEventDelay() determine if the pool this is part
// of has an unstarted thread
void SetPoolThreadFreePtr(mozilla::Atomic* aPtr) {
mIsAPoolThreadFree = aPtr;
}
void SetScriptObserver(mozilla::CycleCollectedJSContext* aScriptObserver);
uint32_t RecursionDepth() const;
void ShutdownComplete(NotNull aContext);
void WaitForAllAsynchronousShutdowns();
static const uint32_t kRunnableNameBufSize = 1000;
static mozilla::Array sMainThreadRunnableName;
mozilla::SynchronizedEventQueue* EventQueue() { return mEvents.get(); }
bool ShuttingDown() const { return mShutdownContext != nullptr; }
static bool GetLabeledRunnableName(nsIRunnable* aEvent, nsACString& aName,
mozilla::EventQueuePriority aPriority);
virtual mozilla::PerformanceCounter* GetPerformanceCounter(
nsIRunnable* aEvent) const;
static mozilla::PerformanceCounter* GetPerformanceCounterBase(
nsIRunnable* aEvent);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
// Returns the size of this object, its PRThread, and its shutdown contexts,
// but excluding its event queues.
size_t ShallowSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfEventQueues(mozilla::MallocSizeOf aMallocSizeOf) const;
static nsThreadEnumerator Enumerate();
// When entering local execution mode a new event queue is created and used as
// an event source. This queue is only accessible through an
// nsLocalExecutionGuard constructed from the nsLocalExecutionRecord returned
// by this function, effectively restricting the events that get run while in
// local execution mode to those dispatched by the owner of the guard object.
//
// Local execution is not nestable. When the nsLocalExecutionGuard is
// destructed, the thread exits the local execution mode.
//
// Note that code run in local execution mode is not considered a task in the
// spec sense. Events from the local queue are considered part of the
// enclosing task and as such do not trigger profiling hooks, observer
// notifications, etc.
nsLocalExecutionRecord EnterLocalExecution();
void SetUseHangMonitor(bool aValue) {
MOZ_ASSERT(IsOnCurrentThread());
mUseHangMonitor = aValue;
}
private:
void DoMainThreadSpecificProcessing() const;
protected:
friend class nsThreadShutdownEvent;
friend class nsThreadEnumerator;
virtual ~nsThread();
static void ThreadFunc(void* aArg);
// Helper
already_AddRefed GetObserver() {
nsIThreadObserver* obs;
nsThread::GetObserver(&obs);
return already_AddRefed(obs);
}
struct nsThreadShutdownContext* ShutdownInternal(bool aSync);
friend class nsThreadManager;
friend class nsThreadPool;
static mozilla::OffTheBooksMutex& ThreadListMutex();
static mozilla::LinkedList& ThreadList();
static void ClearThreadList();
void AddToThreadList();
void MaybeRemoveFromThreadList();
// Whether or not these members have a value determines whether the nsThread
// is treated as a full XPCOM thread or as a thin wrapper.
//
// For full nsThreads, they will always contain valid pointers. For thin
// wrappers around non-XPCOM threads, they will be null, and event dispatch
// methods which rely on them will fail (and assert) if called.
RefPtr mEvents;
RefPtr mEventTarget;
// The shutdown contexts for any other threads we've asked to shut down.
using ShutdownContexts =
nsTArray>;
// Helper for finding a ShutdownContext in the contexts array.
struct ShutdownContextsComp {
bool Equals(const ShutdownContexts::elem_type& a,
const ShutdownContexts::elem_type::Pointer b) const;
};
ShutdownContexts mRequestedShutdownContexts;
// The shutdown context for ourselves.
struct nsThreadShutdownContext* mShutdownContext;
mozilla::CycleCollectedJSContext* mScriptObserver;
void* mStackBase = nullptr;
uint32_t mStackSize;
uint32_t mThreadId;
uint32_t mNestedEventLoopDepth;
mozilla::Atomic mShutdownRequired;
int8_t mPriority;
const bool mIsMainThread;
bool mUseHangMonitor;
mozilla::Atomic* mIsAPoolThreadFree;
// Set to true if this thread creates a JSRuntime.
bool mCanInvokeJS;
bool mHasTLSEntry = false;
// The time the currently running event spent in event queues, and
// when it started running. If no event is running, they are
// TimeDuration() & TimeStamp().
mozilla::TimeDuration mLastEventDelay;
mozilla::TimeStamp mLastEventStart;
#ifdef EARLY_BETA_OR_EARLIER
nsCString mNameForWakeupTelemetry;
mozilla::TimeStamp mLastWakeupCheckTime;
uint32_t mWakeupCount = 0;
#endif
mozilla::PerformanceCounterState mPerformanceCounterState;
bool mIsInLocalExecutionMode = false;
mozilla::SimpleTaskQueue mDirectTasks;
};
Minimal test - lines (399, 417)
path: .spaces[8].metrics.cyclomatic.average
old: 1.0
new: 1.25
path: .spaces[8].metrics.cyclomatic.sum
old: 1.0
new: 5.0
path: .spaces[8].metrics.nargs.average
old: 0.0
new: 1.3333333333333333
path: .spaces[8].metrics.nargs.sum
old: 0.0
new: 4.0
path: .spaces[8].metrics.halstead.n1
old: 8.0
new: 12.0
path: .spaces[8].metrics.halstead.level
old: 0.25
new: 0.07407407407407407
path: .spaces[8].metrics.halstead.effort
old: 215.09775004326937
new: 2975.647493329949
path: .spaces[8].metrics.halstead.length
old: 15.0
new: 51.0
path: .spaces[8].metrics.halstead.bugs
old: 0.011966560027609794
new: 0.06896039383536252
path: .spaces[8].metrics.halstead.difficulty
old: 4.0
new: 13.5
path: .spaces[8].metrics.halstead.N1
old: 11.0
new: 33.0
path: .spaces[8].metrics.halstead.N2
old: 4.0
new: 18.0
path: .spaces[8].metrics.halstead.volume
old: 53.77443751081734
new: 220.4183328392555
path: .spaces[8].metrics.halstead.vocabulary
old: 12.0
new: 20.0
path: .spaces[8].metrics.halstead.purity_ratio
old: 2.1333333333333333
new: 1.3141088236990957
path: .spaces[8].metrics.halstead.time
old: 11.949875002403854
new: 165.31374962944162
path: .spaces[8].metrics.halstead.estimated_program_length
old: 32.0
new: 67.01955000865388
path: .spaces[8].metrics.halstead.n2
old: 4.0
new: 8.0
path: .spaces[8].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[8].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[8].metrics.nom.functions
old: 1.0
new: 3.0
path: .spaces[8].metrics.nom.total
old: 1.0
new: 3.0
path: .spaces[8].metrics.loc.ploc
old: 5.0
new: 15.0
path: .spaces[8].metrics.loc.blank
old: 0.0
new: 4.0
path: .spaces[8].metrics.loc.sloc
old: 5.0
new: 19.0
path: .spaces[8].metrics.loc.lloc
old: 1.0
new: 0.0
path: .spaces[8].metrics.mi.mi_sei
old: 103.26075201909244
new: 60.556252140581904
path: .spaces[8].metrics.mi.mi_visual_studio
old: 72.50067549725833
new: 55.02534901661683
path: .spaces[8].metrics.mi.mi_original
old: 123.97615510031176
new: 94.0933468184148
Code
class MOZ_TEMPORARY_CLASS nsLocalExecutionRecord final {
private:
friend class nsThread;
friend class nsLocalExecutionGuard;
nsLocalExecutionRecord(mozilla::SynchronizedEventQueue& aEventQueueStack,
bool& aLocalExecutionFlag)
: mEventQueueStack(aEventQueueStack),
mLocalExecutionFlag(aLocalExecutionFlag) {}
nsLocalExecutionRecord(nsLocalExecutionRecord&&) = default;
public:
nsLocalExecutionRecord(const nsLocalExecutionRecord&) = delete;
private:
mozilla::SynchronizedEventQueue& mEventQueueStack;
bool& mLocalExecutionFlag;
};
Minimal test - lines (45, 45)
path: .spaces[2].metrics.mi.mi_original
old: 57.21012307619431
new: null
path: .spaces[2].metrics.mi.mi_sei
old: 34.717104882949556
new: null
path: .spaces[2].metrics.mi.mi_visual_studio
old: 33.45621232525983
new: null
path: .spaces[2].metrics.cyclomatic.sum
old: 25.0
new: 1.0
path: .spaces[2].metrics.cyclomatic.average
old: 25.0
new: 1.0
path: .spaces[2].metrics.nexits.average
old: 1.0
new: null
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[2].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[2].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[2].metrics.loc.cloc
old: 8.0
new: 0.0
path: .spaces[2].metrics.loc.ploc
old: 55.0
new: 1.0
path: .spaces[2].metrics.loc.blank
old: 5.0
new: 0.0
path: .spaces[2].metrics.loc.lloc
old: 25.0
new: 0.0
path: .spaces[2].metrics.loc.sloc
old: 68.0
new: 1.0
path: .spaces[2].metrics.cognitive.sum
old: 23.0
new: 0.0
path: .spaces[2].metrics.cognitive.average
old: 23.0
new: null
path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 0.0
path: .spaces[2].metrics.nargs.average
old: 2.0
new: null
path: .spaces[2].metrics.halstead.n2
old: 35.0
new: 1.0
path: .spaces[2].metrics.halstead.N1
old: 200.0
new: 0.0
path: .spaces[2].metrics.halstead.difficulty
old: 58.0
new: 0.0
path: .spaces[2].metrics.halstead.n1
old: 28.0
new: 0.0
path: .spaces[2].metrics.halstead.estimated_program_length
old: 314.1308434106867
new: null
path: .spaces[2].metrics.halstead.N2
old: 145.0
new: 1.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 0.9105241837990918
new: null
path: .spaces[2].metrics.halstead.time
old: 6644.742848290741
new: 0.0
path: .spaces[2].metrics.halstead.bugs
old: 0.8091813556132159
new: 0.0
path: .spaces[2].metrics.halstead.effort
old: 119605.37126923334
new: 0.0
path: .spaces[2].metrics.halstead.vocabulary
old: 63.0
new: 1.0
path: .spaces[2].metrics.halstead.volume
old: 2062.1615736074714
new: 0.0
path: .spaces[2].metrics.halstead.length
old: 345.0
new: 1.0
path: .spaces[2].metrics.halstead.level
old: 0.017241379310344827
new: null
Code
class nsLocalExecutionRecord;