Global Metrics
path: .metrics.cyclomatic.average
old: 1.3333333333333333
new: 1.8333333333333333
path: .metrics.cyclomatic.sum
old: 4.0
new: 11.0
path: .metrics.cognitive.average
old: 2.0
new: 0.5
path: .metrics.loc.lloc
old: 4.0
new: 14.0
path: .metrics.loc.ploc
old: 28.0
new: 46.0
path: .metrics.loc.sloc
old: 58.0
new: 68.0
path: .metrics.loc.blank
old: 10.0
new: 14.0
path: .metrics.loc.cloc
old: 20.0
new: 8.0
path: .metrics.nom.total
old: 1.0
new: 4.0
path: .metrics.nom.functions
old: 1.0
new: 4.0
path: .metrics.halstead.time
old: 332.21399714097174
new: 1380.54803191189
path: .metrics.halstead.n2
old: 23.0
new: 49.0
path: .metrics.halstead.bugs
old: 0.10981770574434908
new: 0.2838538328261023
path: .metrics.halstead.vocabulary
old: 35.0
new: 70.0
path: .metrics.halstead.volume
old: 559.0918488470013
new: 1317.7958486431678
path: .metrics.halstead.estimated_program_length
old: 147.06147499796518
new: 367.3594482399991
path: .metrics.halstead.N2
old: 41.0
new: 88.0
path: .metrics.halstead.effort
old: 5979.851948537492
new: 24849.864574414023
path: .metrics.halstead.difficulty
old: 10.695652173913045
new: 18.857142857142858
path: .metrics.halstead.length
old: 109.0
new: 215.0
path: .metrics.halstead.N1
old: 68.0
new: 127.0
path: .metrics.halstead.n1
old: 12.0
new: 21.0
path: .metrics.halstead.purity_ratio
old: 1.3491878440180292
new: 1.7086485964651124
path: .metrics.halstead.level
old: 0.0934959349593496
new: 0.05303030303030303
path: .metrics.nexits.average
old: 0.0
new: 1.0
path: .metrics.nexits.sum
old: 0.0
new: 4.0
path: .metrics.nargs.sum
old: 3.0
new: 2.0
path: .metrics.nargs.average
old: 3.0
new: 0.5
path: .metrics.mi.mi_visual_studio
old: 41.75672025207502
new: 36.70096665100009
path: .metrics.mi.mi_original
old: 71.40399163104829
new: 62.75865297321015
path: .metrics.mi.mi_sei
old: 67.18713299732191
new: 41.29646341793601
Spaces Data
Minimal test - lines (12, 68)
path: .spaces[0].metrics.nargs.average
old: 3.0
new: 0.5
path: .spaces[0].metrics.nargs.sum
old: 3.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.5
new: 2.0
path: .spaces[0].metrics.cyclomatic.sum
old: 3.0
new: 10.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 4.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 4.0
path: .spaces[0].metrics.cognitive.average
old: 2.0
new: 0.5
path: .spaces[0].metrics.loc.blank
old: 5.0
new: 12.0
path: .spaces[0].metrics.loc.sloc
old: 37.0
new: 57.0
path: .spaces[0].metrics.loc.ploc
old: 24.0
new: 43.0
path: .spaces[0].metrics.loc.cloc
old: 8.0
new: 2.0
path: .spaces[0].metrics.loc.lloc
old: 4.0
new: 14.0
path: .spaces[0].metrics.halstead.length
old: 105.0
new: 212.0
path: .spaces[0].metrics.halstead.difficulty
old: 10.857142857142858
new: 19.402173913043477
path: .spaces[0].metrics.halstead.vocabulary
old: 33.0
new: 67.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 135.25821588700785
new: 346.32251585697657
path: .spaces[0].metrics.halstead.n2
old: 21.0
new: 46.0
path: .spaces[0].metrics.halstead.level
old: 0.09210526315789472
new: 0.05154061624649861
path: .spaces[0].metrics.halstead.effort
old: 5750.609296068637
new: 24951.407298402497
path: .spaces[0].metrics.halstead.N1
old: 67.0
new: 127.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.28817348463817
new: 1.6335967729102667
path: .spaces[0].metrics.halstead.bugs
old: 0.10699282467908512
new: 0.2846265720368962
path: .spaces[0].metrics.halstead.volume
old: 529.6613825326376
new: 1286.0109083770476
path: .spaces[0].metrics.halstead.n1
old: 12.0
new: 21.0
path: .spaces[0].metrics.halstead.time
old: 319.4782942260354
new: 1386.1892943556943
path: .spaces[0].metrics.halstead.N2
old: 38.0
new: 85.0
path: .spaces[0].metrics.mi.mi_sei
old: 71.84521171458925
new: 34.80474678432542
path: .spaces[0].metrics.mi.mi_original
old: 79.19749272746645
new: 65.97420744779696
path: .spaces[0].metrics.mi.mi_visual_studio
old: 46.31432323243652
new: 38.58140786420874
path: .spaces[0].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 4.0
Code
namespace mozilla {
/*static*/ InputEventStatistics& InputEventStatistics::Get() {
static UniquePtr sInstance;
if (!sInstance) {
sInstance = MakeUnique(ConstructorCookie());
ClearOnShutdown(&sInstance);
}
return *sInstance;
}
TimeDuration InputEventStatistics::TimeDurationCircularBuffer::GetMean() {
return mTotal / (int64_t)mSize;
}
InputEventStatistics::InputEventStatistics(ConstructorCookie&&)
: mEnable(false) {
MOZ_ASSERT(Preferences::IsServiceAvailable());
uint32_t inputDuration = Preferences::GetUint(
"input_event_queue.default_duration_per_event", sDefaultInputDuration);
TimeDuration defaultDuration = TimeDuration::FromMilliseconds(inputDuration);
uint32_t count = Preferences::GetUint(
"input_event_queue.count_for_prediction", sInputCountForPrediction);
mLastInputDurations =
MakeUnique(count, defaultDuration);
uint32_t maxDuration = Preferences::GetUint("input_event_queue.duration.max",
sMaxReservedTimeForHandlingInput);
uint32_t minDuration = Preferences::GetUint("input_event_queue.duration.min",
sMinReservedTimeForHandlingInput);
mMaxInputDuration = TimeDuration::FromMilliseconds(maxDuration);
mMinInputDuration = TimeDuration::FromMilliseconds(minDuration);
}
TimeStamp InputEventStatistics::GetInputHandlingStartTime(
uint32_t aInputCount) {
MOZ_ASSERT(mEnable);
Maybe nextTickHint = nsRefreshDriver::GetNextTickHint();
if (nextTickHint.isNothing()) {
// Return a past time to process input events immediately.
return TimeStamp::Now() - TimeDuration::FromMilliseconds(1);
}
TimeDuration inputCost = mLastInputDurations->GetMean() * aInputCount;
inputCost = inputCost > mMaxInputDuration ? mMaxInputDuration
: inputCost < mMinInputDuration ? mMinInputDuration
: inputCost;
return nextTickHint.value() - inputCost;
}
} // namespace mozilla
Minimal test - lines (14, 21)
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 82.02029673398083
new: 84.2052424217006
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 63.84960073517885
new: 64.7352667837868
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 109.18281725715585
new: 110.69730620027542
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 9.0
new: 8.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 9.0
new: 8.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 3.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nargs.average
old: 3.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 1151.9417816484386
new: 1704.0257796785124
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 18.0
new: 19.0
path: .spaces[0].spaces[0].metrics.halstead.length
old: 34.0
new: 36.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 21.0
new: 23.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 10.0
new: 12.0
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.03662962161471501
new: 0.04755499997750479
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 57.219280948873624
new: 62.6710344630571
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.12307692307692308
new: 0.08974358974358974
path: .spaces[0].spaces[0].metrics.halstead.time
old: 63.99676564713547
new: 94.66809887102846
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 141.7774500490386
new: 152.92539048396907
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 8.0
new: 7.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 8.125
new: 11.142857142857142
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.6829200279080478
new: 1.7408620684182528
path: .spaces[0].spaces[0].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 2.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 2.0
new: 1.0
Code
/*static*/ InputEventStatistics& InputEventStatistics::Get() {
static UniquePtr sInstance;
if (!sInstance) {
sInstance = MakeUnique(ConstructorCookie());
ClearOnShutdown(&sInstance);
}
return *sInstance;
}