Global Metrics
path: .metrics.mi.mi_sei
old: -49.27693033065511
new: -4.4683593127109305
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 12.991087272418008
path: .metrics.mi.mi_original
old: -1.597500503673146
new: 22.21475923583479
path: .metrics.halstead.N1
old: 1121.0
new: 764.0
path: .metrics.halstead.length
old: 1810.0
new: 1259.0
path: .metrics.halstead.vocabulary
old: 281.0
new: 142.0
path: .metrics.halstead.purity_ratio
old: 1.183447779604946
new: 0.7272544228888139
path: .metrics.halstead.time
old: 36213.69645581193
new: 29059.292306158142
path: .metrics.halstead.volume
old: 14723.311639599877
new: 9001.531623456394
path: .metrics.halstead.n2
old: 249.0
new: 115.0
path: .metrics.halstead.difficulty
old: 44.273092369477915
new: 58.108695652173914
path: .metrics.halstead.effort
old: 651846.5362046147
new: 523067.26151084655
path: .metrics.halstead.N2
old: 689.0
new: 495.0
path: .metrics.halstead.level
old: 0.02258708272859216
new: 0.01720912832023943
path: .metrics.halstead.bugs
old: 2.5059687639045896
new: 2.163966023910754
path: .metrics.halstead.estimated_program_length
old: 2142.0404810849523
new: 915.6133184170168
path: .metrics.halstead.n1
old: 32.0
new: 27.0
path: .metrics.loc.cloc
old: 23.0
new: 75.0
path: .metrics.loc.sloc
old: 420.0
new: 297.0
path: .metrics.loc.ploc
old: 332.0
new: 188.0
path: .metrics.loc.blank
old: 65.0
new: 34.0
path: .metrics.loc.lloc
old: 125.0
new: 82.0
path: .metrics.cognitive.average
old: 0.6774193548387096
new: 3.75
path: .metrics.cognitive.sum
old: 42.0
new: 45.0
path: .metrics.nargs.average
old: 1.0806451612903225
new: 0.8333333333333334
path: .metrics.nargs.sum
old: 67.0
new: 10.0
path: .metrics.cyclomatic.average
old: 1.6875
new: 4.444444444444445
path: .metrics.cyclomatic.sum
old: 108.0
new: 40.0
path: .metrics.nexits.average
old: 0.9193548387096774
new: 0.08333333333333333
path: .metrics.nexits.sum
old: 57.0
new: 1.0
path: .metrics.nom.closures
old: 2.0
new: 6.0
path: .metrics.nom.functions
old: 60.0
new: 6.0
path: .metrics.nom.total
old: 62.0
new: 12.0
Spaces Data
Minimal test - lines (230, 276)
path: .spaces[5].metrics.nom.functions
old: 1.0
new: 2.0
path: .spaces[5].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[5].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[5].metrics.nargs.average
old: 0.0
new: 0.5
path: .spaces[5].metrics.cyclomatic.average
old: 1.0
new: 2.3333333333333335
path: .spaces[5].metrics.cyclomatic.sum
old: 1.0
new: 7.0
path: .spaces[5].metrics.mi.mi_original
old: 132.6102931370529
new: 69.82417037988272
path: .spaces[5].metrics.mi.mi_sei
old: 115.71718014704972
new: 49.949982823702754
path: .spaces[5].metrics.mi.mi_visual_studio
old: 77.54987902751634
new: 40.83284817537001
path: .spaces[5].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[5].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[5].metrics.cognitive.sum
old: 0.0
new: 5.0
path: .spaces[5].metrics.cognitive.average
old: 0.0
new: 2.5
path: .spaces[5].metrics.loc.lloc
old: 1.0
new: 13.0
path: .spaces[5].metrics.loc.cloc
old: 0.0
new: 5.0
path: .spaces[5].metrics.loc.sloc
old: 3.0
new: 47.0
path: .spaces[5].metrics.loc.blank
old: 0.0
new: 6.0
path: .spaces[5].metrics.loc.ploc
old: 3.0
new: 36.0
path: .spaces[5].metrics.halstead.difficulty
old: 3.5
new: 25.457142857142856
path: .spaces[5].metrics.halstead.bugs
old: 0.010455204778755302
new: 0.3396021673208899
path: .spaces[5].metrics.halstead.n1
old: 7.0
new: 22.0
path: .spaces[5].metrics.halstead.N2
old: 5.0
new: 81.0
path: .spaces[5].metrics.halstead.vocabulary
old: 12.0
new: 57.0
path: .spaces[5].metrics.halstead.purity_ratio
old: 2.2329374949171457
new: 1.26772785937486
path: .spaces[5].metrics.halstead.N1
old: 9.0
new: 138.0
path: .spaces[5].metrics.halstead.effort
old: 175.66316253533665
new: 32519.028444970052
path: .spaces[5].metrics.halstead.n2
old: 5.0
new: 35.0
path: .spaces[5].metrics.halstead.estimated_program_length
old: 31.26112492884004
new: 277.63240120309433
path: .spaces[5].metrics.halstead.length
old: 14.0
new: 219.0
path: .spaces[5].metrics.halstead.level
old: 0.2857142857142857
new: 0.03928170594837262
path: .spaces[5].metrics.halstead.volume
old: 50.18947501009619
new: 1277.4029131020784
path: .spaces[5].metrics.halstead.time
old: 9.75906458529648
new: 1806.6126913872251
Code
class BenchCollections : public ::testing::Test {
protected:
void SetUp() override {
StaticMutexAutoLock lock(sValsMutex);
if (!sVals) {
sVals = (void**)malloc(VALS_LEN * sizeof(void*));
for (size_t i = 0; i < VALS_LEN; i++) {
// This leaves the high 32 bits zero on 64-bit platforms, but that
// should still be enough randomness to get typical behaviour.
sVals[i] = reinterpret_cast(uintptr_t(MyRand()));
}
}
printf("\n");
for (size_t i = 0; i < ArrayLength(gParamsList); i++) {
const Params* params = &gParamsList[i];
printf("%14s", params->mConfigName);
}
printf("%14s\n", "total");
}
public:
void BenchImpl(void (*aBench)(const Params*, void**, size_t)) {
StaticMutexAutoLock lock(sValsMutex);
double total = 0;
for (size_t i = 0; i < ArrayLength(gParamsList); i++) {
const Params* params = &gParamsList[i];
TimeStamp t1 = TimeStamp::Now();
aBench(params, sVals, VALS_LEN);
TimeStamp t2 = TimeStamp::Now();
double t = (t2 - t1).ToMilliseconds();
printf("%11.1f ms", t);
total += t;
}
printf("%11.1f ms\n", total);
}
private:
// Random values used in the benchmarks.
static void** sVals;
// A mutex that protects all benchmark operations, ensuring that two
// benchmarks never run concurrently.
static StaticMutex sValsMutex;
};
Minimal test - lines (127, 166)
path: .spaces[3].metrics.nargs.sum
old: 1.0
new: 3.0
path: .spaces[3].metrics.nargs.average
old: 1.0
new: 3.0
path: .spaces[3].metrics.cyclomatic.average
old: 3.0
new: 10.0
path: .spaces[3].metrics.cyclomatic.sum
old: 3.0
new: 10.0
path: .spaces[3].metrics.loc.ploc
old: 7.0
new: 35.0
path: .spaces[3].metrics.loc.sloc
old: 7.0
new: 40.0
path: .spaces[3].metrics.loc.lloc
old: 1.0
new: 19.0
path: .spaces[3].metrics.loc.blank
old: 0.0
new: 5.0
path: .spaces[3].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[3].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 14.0
path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 14.0
path: .spaces[3].metrics.halstead.volume
old: 159.91133951083242
new: 1559.916969042161
path: .spaces[3].metrics.halstead.bugs
old: 0.03143620862415421
new: 0.46083360088663206
path: .spaces[3].metrics.halstead.level
old: 0.1746031746031746
new: 0.030346135609293504
path: .spaces[3].metrics.halstead.time
old: 50.88088075344668
new: 2855.785492803748
path: .spaces[3].metrics.halstead.effort
old: 915.8558535620402
new: 51404.13887046747
path: .spaces[3].metrics.halstead.N2
old: 14.0
new: 111.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.7995425085943535
new: 0.8753113554742841
path: .spaces[3].metrics.halstead.N1
old: 23.0
new: 164.0
path: .spaces[3].metrics.halstead.difficulty
old: 5.7272727272727275
new: 32.953125
path: .spaces[3].metrics.halstead.length
old: 37.0
new: 275.0
path: .spaces[3].metrics.halstead.vocabulary
old: 20.0
new: 51.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 66.58307281799108
new: 240.71062275542812
path: .spaces[3].metrics.halstead.n1
old: 9.0
new: 19.0
path: .spaces[3].metrics.halstead.n2
old: 11.0
new: 32.0
path: .spaces[3].metrics.mi.mi_original
old: 112.39823401063155
new: 70.70773589931285
path: .spaces[3].metrics.mi.mi_sei
old: 86.76098239801604
new: 27.32704653645706
path: .spaces[3].metrics.mi.mi_visual_studio
old: 65.72996140972606
new: 41.34955315749289
Code
static void Bench_Cpp_PLDHashTable(const Params* aParams, void** aVals,
size_t aLen) {
PLDHashTable hs(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub));
for (size_t j = 0; j < aParams->mNumInserts; j++) {
auto entry = static_cast(hs.Add(aVals[j]));
MOZ_RELEASE_ASSERT(!entry->key);
entry->key = aVals[j];
}
for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
MOZ_RELEASE_ASSERT(hs.Search(aVals[j]));
}
}
for (size_t i = 0; i < aParams->mNumFailingLookups; i++) {
for (size_t j = aParams->mNumInserts; j < aParams->mNumInserts * 2; j++) {
MOZ_RELEASE_ASSERT(!hs.Search(aVals[j]));
}
}
for (size_t i = 0; i < aParams->mNumIterations; i++) {
size_t n = 0;
for (auto iter = hs.Iter(); !iter.Done(); iter.Next()) {
n++;
}
MOZ_RELEASE_ASSERT(aParams->mNumInserts == n);
MOZ_RELEASE_ASSERT(hs.EntryCount() == n);
}
if (aParams->mRemoveInserts) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
hs.Remove(aVals[j]);
}
MOZ_RELEASE_ASSERT(hs.EntryCount() == 0);
} else {
MOZ_RELEASE_ASSERT(hs.EntryCount() == aParams->mNumInserts);
}
}
Minimal test - lines (169, 206)
path: .spaces[4].metrics.loc.sloc
old: 12.0
new: 38.0
path: .spaces[4].metrics.loc.lloc
old: 4.0
new: 18.0
path: .spaces[4].metrics.loc.ploc
old: 11.0
new: 33.0
path: .spaces[4].metrics.loc.blank
old: 1.0
new: 5.0
path: .spaces[4].metrics.nexits.average
old: 0.5
new: 0.0
path: .spaces[4].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[4].metrics.halstead.vocabulary
old: 35.0
new: 46.0
path: .spaces[4].metrics.halstead.length
old: 79.0
new: 260.0
path: .spaces[4].metrics.halstead.level
old: 0.06785714285714285
new: 0.028139656070870243
path: .spaces[4].metrics.halstead.time
old: 331.7536267100078
new: 2835.314817237743
path: .spaces[4].metrics.halstead.difficulty
old: 14.736842105263158
new: 35.53703703703704
path: .spaces[4].metrics.halstead.n1
old: 16.0
new: 19.0
path: .spaces[4].metrics.halstead.N1
old: 44.0
new: 159.0
path: .spaces[4].metrics.halstead.n2
old: 19.0
new: 27.0
path: .spaces[4].metrics.halstead.bugs
old: 0.10971622796436908
new: 0.4586287477527153
path: .spaces[4].metrics.halstead.effort
old: 5971.56528078014
new: 51035.66671027937
path: .spaces[4].metrics.halstead.estimated_program_length
old: 144.71062275542812
new: 209.09258531384177
path: .spaces[4].metrics.halstead.purity_ratio
old: 1.831780034878837
new: 0.8042022512070837
path: .spaces[4].metrics.halstead.N2
old: 35.0
new: 101.0
path: .spaces[4].metrics.halstead.volume
old: 405.2133583386524
new: 1436.126108574823
path: .spaces[4].metrics.cyclomatic.average
old: 2.0
new: 10.0
path: .spaces[4].metrics.cyclomatic.sum
old: 2.0
new: 10.0
path: .spaces[4].metrics.cognitive.average
old: 0.0
new: 14.0
path: .spaces[4].metrics.cognitive.sum
old: 0.0
new: 14.0
path: .spaces[4].metrics.mi.mi_sei
old: 67.41841027909851
new: 29.146147313310703
path: .spaces[4].metrics.mi.mi_original
old: 99.06156083009768
new: 71.96864047394334
path: .spaces[4].metrics.mi.mi_visual_studio
old: 57.9307373275425
new: 42.08692425376804
path: .spaces[4].metrics.nargs.sum
old: 0.0
new: 3.0
path: .spaces[4].metrics.nargs.average
old: 0.0
new: 3.0
path: .spaces[4].metrics.nom.total
old: 2.0
new: 1.0
path: .spaces[4].metrics.nom.closures
old: 1.0
new: 0.0
Code
static void Bench_Cpp_MozHashSet(const Params* aParams, void** aVals,
size_t aLen) {
mozilla::HashSet, MallocAllocPolicy> hs;
for (size_t j = 0; j < aParams->mNumInserts; j++) {
MOZ_RELEASE_ASSERT(hs.put(aVals[j]));
}
for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
MOZ_RELEASE_ASSERT(hs.has(aVals[j]));
}
}
for (size_t i = 0; i < aParams->mNumFailingLookups; i++) {
for (size_t j = aParams->mNumInserts; j < aParams->mNumInserts * 2; j++) {
MOZ_RELEASE_ASSERT(!hs.has(aVals[j]));
}
}
for (size_t i = 0; i < aParams->mNumIterations; i++) {
size_t n = 0;
for (auto iter = hs.iter(); !iter.done(); iter.next()) {
n++;
}
MOZ_RELEASE_ASSERT(aParams->mNumInserts == n);
MOZ_RELEASE_ASSERT(hs.count() == n);
}
if (aParams->mRemoveInserts) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
hs.remove(aVals[j]);
}
MOZ_RELEASE_ASSERT(hs.count() == 0);
} else {
MOZ_RELEASE_ASSERT(hs.count() == aParams->mNumInserts);
}
}
Minimal test - lines (86, 124)
path: .spaces[2].metrics.nom.total
old: 20.0
new: 1.0
path: .spaces[2].metrics.nom.functions
old: 20.0
new: 1.0
path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 10.0
path: .spaces[2].metrics.cyclomatic.sum
old: 23.0
new: 10.0
path: .spaces[2].metrics.mi.mi_visual_studio
old: 36.62608901545465
new: 41.92383434743167
path: .spaces[2].metrics.mi.mi_sei
old: 16.997878426769475
new: 28.74380312486589
path: .spaces[2].metrics.mi.mi_original
old: 62.63061221642745
new: 71.68975673410816
path: .spaces[2].metrics.halstead.bugs
old: 0.22666533570873587
new: 0.503428857069371
path: .spaces[2].metrics.halstead.n1
old: 16.0
new: 21.0
path: .spaces[2].metrics.halstead.level
old: 0.08676470588235294
new: 0.023809523809523808
path: .spaces[2].metrics.halstead.estimated_program_length
old: 411.07593991234864
new: 208.33507062272207
path: .spaces[2].metrics.halstead.effort
old: 17732.0743602659
new: 58693.36934506182
path: .spaces[2].metrics.halstead.N2
old: 85.0
new: 100.0
path: .spaces[2].metrics.halstead.difficulty
old: 11.52542372881356
new: 42.0
path: .spaces[2].metrics.halstead.volume
old: 1538.5182165524825
new: 1397.4611748824243
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.6642750603738812
new: 0.8234587771649093
path: .spaces[2].metrics.halstead.vocabulary
old: 75.0
new: 46.0
path: .spaces[2].metrics.halstead.length
old: 247.0
new: 253.0
path: .spaces[2].metrics.halstead.n2
old: 59.0
new: 25.0
path: .spaces[2].metrics.halstead.time
old: 985.1152422369944
new: 3260.7427413923233
path: .spaces[2].metrics.halstead.N1
old: 162.0
new: 153.0
path: .spaces[2].metrics.nexits.average
old: 0.65
new: 0.0
path: .spaces[2].metrics.nexits.sum
old: 13.0
new: 0.0
path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 12.0
path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 12.0
path: .spaces[2].metrics.loc.ploc
old: 52.0
new: 34.0
path: .spaces[2].metrics.loc.sloc
old: 55.0
new: 39.0
path: .spaces[2].metrics.loc.blank
old: 3.0
new: 5.0
path: .spaces[2].metrics.loc.lloc
old: 15.0
new: 18.0
path: .spaces[2].metrics.nargs.sum
old: 21.0
new: 3.0
path: .spaces[2].metrics.nargs.average
old: 1.05
new: 3.0
Code
static void Bench_Cpp_unordered_set(const Params* aParams, void** aVals,
size_t aLen) {
std::unordered_set hs;
for (size_t j = 0; j < aParams->mNumInserts; j++) {
hs.insert(aVals[j]);
}
for (size_t i = 0; i < aParams->mNumSuccessfulLookups; i++) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
MOZ_RELEASE_ASSERT(hs.find(aVals[j]) != hs.end());
}
}
for (size_t i = 0; i < aParams->mNumFailingLookups; i++) {
for (size_t j = aParams->mNumInserts; j < aParams->mNumInserts * 2; j++) {
MOZ_RELEASE_ASSERT(hs.find(aVals[j]) == hs.end());
}
}
for (size_t i = 0; i < aParams->mNumIterations; i++) {
size_t n = 0;
for (const auto& elem : hs) {
(void)elem;
n++;
}
MOZ_RELEASE_ASSERT(aParams->mNumInserts == n);
MOZ_RELEASE_ASSERT(hs.size() == n);
}
if (aParams->mRemoveInserts) {
for (size_t j = 0; j < aParams->mNumInserts; j++) {
MOZ_RELEASE_ASSERT(hs.erase(aVals[j]) == 1);
}
MOZ_RELEASE_ASSERT(hs.size() == 0);
} else {
MOZ_RELEASE_ASSERT(hs.size() == aParams->mNumInserts);
}
}
Minimal test - lines (66, 70)
path: .spaces[0].metrics.halstead.N1
old: 14.0
new: 12.0
path: .spaces[0].metrics.halstead.time
old: 22.790195141049693
new: 26.31423799566999
path: .spaces[0].metrics.halstead.level
old: 0.22857142857142856
new: 0.15625
path: .spaces[0].metrics.halstead.length
old: 24.0
new: 20.0
path: .spaces[0].metrics.halstead.difficulty
old: 4.375
new: 6.4
path: .spaces[0].metrics.halstead.vocabulary
old: 15.0
new: 13.0
path: .spaces[0].metrics.halstead.n2
old: 8.0
new: 5.0
path: .spaces[0].metrics.halstead.n1
old: 7.0
new: 8.0
path: .spaces[0].metrics.halstead.bugs
old: 0.01840316180582329
new: 0.020254472988841275
path: .spaces[0].metrics.halstead.volume
old: 93.76537429460444
new: 74.00879436282185
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.8188118522668013
new: 1.7804820237218404
path: .spaces[0].metrics.halstead.estimated_program_length
old: 43.65148445440323
new: 35.60964047443681
path: .spaces[0].metrics.halstead.N2
old: 10.0
new: 8.0
path: .spaces[0].metrics.halstead.effort
old: 410.22351253889445
new: 473.65628392205986
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[0].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 2.0
path: .spaces[0].metrics.loc.sloc
old: 2.0
new: 5.0
path: .spaces[0].metrics.loc.ploc
old: 2.0
new: 5.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 79.49057212090507
new: 71.52944408676726
path: .spaces[0].metrics.mi.mi_sei
old: 120.50488654298988
new: 100.86471585459692
path: .spaces[0].metrics.mi.mi_original
old: 135.92887832674768
new: 122.315349388372
path: .spaces[0].metrics.nargs.average
old: 2.0
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 2.0
new: 0.0
Code
static uintptr_t MyRand() {
static uintptr_t s = 0;
s = s * 1103515245 + 12345;
return s;
}
Minimal test - lines (73, 80)
path: .spaces[1].metrics.nexits.average
old: 0.0
new: null
path: .spaces[1].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[1].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[1].metrics.halstead.estimated_program_length
old: 8.0
new: 27.651484454403228
path: .spaces[1].metrics.halstead.n2
old: 1.0
new: 7.0
path: .spaces[1].metrics.halstead.N1
old: 4.0
new: 14.0
path: .spaces[1].metrics.halstead.volume
old: 11.60964047443681
new: 72.64806399138324
path: .spaces[1].metrics.halstead.length
old: 5.0
new: 21.0
path: .spaces[1].metrics.halstead.effort
old: 23.21928094887362
new: 145.29612798276648
path: .spaces[1].metrics.halstead.vocabulary
old: 5.0
new: 11.0
path: .spaces[1].metrics.halstead.bugs
old: 0.002712967490108627
new: 0.00921258354248177
path: .spaces[1].metrics.halstead.N2
old: 1.0
new: 7.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.6
new: 1.3167373549715822
path: .spaces[1].metrics.halstead.time
old: 1.289960052715201
new: 8.072007110153693
path: .spaces[1].metrics.cognitive.average
old: 0.0
new: null
path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 5.0
path: .spaces[1].metrics.loc.sloc
old: 1.0
new: 8.0
path: .spaces[1].metrics.loc.ploc
old: 1.0
new: 8.0
path: .spaces[1].metrics.mi.mi_sei
old: 152.37629276875444
new: 137.05513396437843
path: .spaces[1].metrics.mi.mi_visual_studio
old: 92.40962204246613
new: 67.13320933941348
path: .spaces[1].metrics.mi.mi_original
old: 158.02045369261705
new: 114.79778797039704
path: .spaces[1].metrics.nargs.average
old: 0.0
new: null
Code
struct Params {
const char* mConfigName;
size_t mNumInserts; // Insert this many unique keys
size_t mNumSuccessfulLookups; // Does mNumInserts lookups each time
size_t mNumFailingLookups; // Does mNumInserts lookups each time
size_t mNumIterations; // Iterates the full table each time
bool mRemoveInserts; // Remove all entries at end?
};