Global Metrics
path: .metrics.halstead.volume
old: 27627.009124579883
new: 1894.550497376189
path: .metrics.halstead.time
old: 105025.10806269362
new: 3029.7771842960483
path: .metrics.halstead.n1
old: 32.0
new: 26.0
path: .metrics.halstead.estimated_program_length
old: 2803.4967797804247
new: 447.42330830689417
path: .metrics.halstead.n2
old: 318.0
new: 56.0
path: .metrics.halstead.length
old: 3269.0
new: 298.0
path: .metrics.halstead.N1
old: 1909.0
new: 174.0
path: .metrics.halstead.difficulty
old: 68.42767295597484
new: 28.785714285714285
path: .metrics.halstead.bugs
old: 5.096310029606826
new: 0.4793663476710026
path: .metrics.halstead.vocabulary
old: 350.0
new: 82.0
path: .metrics.halstead.level
old: 0.014613970588235294
new: 0.034739454094292806
path: .metrics.halstead.effort
old: 1890451.945128485
new: 54535.989317328866
path: .metrics.halstead.N2
old: 1360.0
new: 124.0
path: .metrics.halstead.purity_ratio
old: 0.8576007279842229
new: 1.5014204976741414
path: .metrics.cognitive.sum
old: 262.0
new: 14.0
path: .metrics.cognitive.average
old: 29.11111111111111
new: 7.0
path: .metrics.loc.lloc
old: 498.0
new: 17.0
path: .metrics.loc.cloc
old: 86.0
new: 15.0
path: .metrics.loc.sloc
old: 996.0
new: 75.0
path: .metrics.loc.blank
old: 50.0
new: 13.0
path: .metrics.loc.ploc
old: 860.0
new: 47.0
path: .metrics.nexits.average
old: 6.777777777777778
new: 2.0
path: .metrics.nexits.sum
old: 61.0
new: 4.0
path: .metrics.nargs.average
old: 1.1111111111111112
new: 1.0
path: .metrics.nargs.sum
old: 10.0
new: 2.0
path: .metrics.nom.functions
old: 9.0
new: 2.0
path: .metrics.nom.total
old: 9.0
new: 2.0
path: .metrics.cyclomatic.sum
old: 177.0
new: 15.0
path: .metrics.cyclomatic.average
old: 17.7
new: 5.0
path: .metrics.mi.mi_original
old: -34.72876122913914
new: 58.36366075960487
path: .metrics.mi.mi_sei
old: -85.79857155931953
new: 41.9629003779122
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 34.130795765850806
Spaces Data
Minimal test - lines (45, 75)
path: .spaces[1].metrics.nexits.sum
old: 5.0
new: 2.0
path: .spaces[1].metrics.nexits.average
old: 5.0
new: 2.0
path: .spaces[1].metrics.halstead.volume
old: 1010.2502579696755
new: 761.9205856195878
path: .spaces[1].metrics.halstead.bugs
old: 0.17645049368086155
new: 0.2018096477193206
path: .spaces[1].metrics.halstead.difficulty
old: 12.055555555555555
new: 19.551724137931036
path: .spaces[1].metrics.halstead.N2
old: 62.0
new: 54.0
path: .spaces[1].metrics.halstead.length
old: 179.0
new: 135.0
path: .spaces[1].metrics.halstead.level
old: 0.08294930875576037
new: 0.05114638447971781
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.3375434020152497
new: 1.726815664718915
path: .spaces[1].metrics.halstead.n2
old: 36.0
new: 29.0
path: .spaces[1].metrics.halstead.effort
old: 12179.128109967756
new: 14896.861105045044
path: .spaces[1].metrics.halstead.estimated_program_length
old: 239.4202689607297
new: 233.1201147370535
path: .spaces[1].metrics.halstead.N1
old: 117.0
new: 81.0
path: .spaces[1].metrics.halstead.time
old: 676.618228331542
new: 827.6033947247247
path: .spaces[1].metrics.halstead.n1
old: 14.0
new: 21.0
path: .spaces[1].metrics.loc.ploc
old: 54.0
new: 22.0
path: .spaces[1].metrics.loc.cloc
old: 1.0
new: 5.0
path: .spaces[1].metrics.loc.blank
old: 1.0
new: 4.0
path: .spaces[1].metrics.loc.lloc
old: 41.0
new: 10.0
path: .spaces[1].metrics.loc.sloc
old: 56.0
new: 31.0
path: .spaces[1].metrics.mi.mi_original
old: 65.21594514167407
new: 79.02302716141622
path: .spaces[1].metrics.mi.mi_sei
old: 30.699471905196553
new: 68.25987296917765
path: .spaces[1].metrics.mi.mi_visual_studio
old: 38.137979615014075
new: 46.21229658562352
path: .spaces[1].metrics.cyclomatic.sum
old: 20.0
new: 8.0
path: .spaces[1].metrics.cyclomatic.average
old: 20.0
new: 8.0
path: .spaces[1].metrics.nargs.sum
old: 0.0
new: 2.0
path: .spaces[1].metrics.nargs.average
old: 0.0
new: 2.0
Code
bool ProfilerCodeAddressService::GetFunction(const void* aPc,
nsACString& aResult) {
Entry& entry = GetEntry(aPc);
#if defined(XP_LINUX) || defined(XP_FREEBSD)
// On Linux, most symbols will not be found by the MozDescribeCodeAddress call
// that GetEntry does. So we read the symbol table directly from the ELF
// image.
// SymbolTable currently assumes library offsets will not be larger than
// 4 GiB.
if (entry.mLOffset <= 0xFFFFFFFF && !entry.mFunction) {
auto p = mSymbolTables.lookupForAdd(entry.mLibrary);
if (!p) {
if (!mSymbolTables.add(p, entry.mLibrary, SymbolTable())) {
MOZ_CRASH("ProfilerCodeAddressService OOM");
}
profiler_get_symbol_table(entry.mLibrary, nullptr, &p->value());
}
entry.mFunction =
SearchSymbolTable(p->value(), static_cast(entry.mLOffset));
}
#endif
if (!entry.mFunction || entry.mFunction[0] == '\0') {
return false;
}
aResult = nsDependentCString(entry.mFunction);
return true;
}
Minimal test - lines (15, 42)
path: .spaces[0].metrics.cognitive.sum
old: 160.0
new: 3.0
path: .spaces[0].metrics.cognitive.average
old: 160.0
new: 3.0
path: .spaces[0].metrics.cyclomatic.sum
old: 85.0
new: 5.0
path: .spaces[0].metrics.cyclomatic.average
old: 85.0
new: 5.0
path: .spaces[0].metrics.nexits.sum
old: 49.0
new: 2.0
path: .spaces[0].metrics.nexits.average
old: 49.0
new: 2.0
path: .spaces[0].metrics.halstead.N2
old: 580.0
new: 64.0
path: .spaces[0].metrics.halstead.length
old: 1427.0
new: 153.0
path: .spaces[0].metrics.halstead.n1
old: 24.0
new: 22.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 0.46991954040374706
new: 1.4803232560028377
path: .spaces[0].metrics.halstead.vocabulary
old: 111.0
new: 49.0
path: .spaces[0].metrics.halstead.bugs
old: 2.8139916355435366
new: 0.2648686193054141
path: .spaces[0].metrics.halstead.N1
old: 847.0
new: 89.0
path: .spaces[0].metrics.halstead.effort
old: 775650.515302528
new: 22398.949138123604
path: .spaces[0].metrics.halstead.estimated_program_length
old: 670.5751841561471
new: 226.48945816843417
path: .spaces[0].metrics.halstead.difficulty
old: 80.0
new: 26.074074074074073
path: .spaces[0].metrics.halstead.level
old: 0.0125
new: 0.03835227272727273
path: .spaces[0].metrics.halstead.volume
old: 9695.6314412816
new: 859.0506061496269
path: .spaces[0].metrics.halstead.time
old: 43091.69529458489
new: 1244.3860632290891
path: .spaces[0].metrics.halstead.n2
old: 87.0
new: 27.0
path: .spaces[0].metrics.loc.ploc
old: 313.0
new: 19.0
path: .spaces[0].metrics.loc.sloc
old: 323.0
new: 28.0
path: .spaces[0].metrics.loc.cloc
old: 6.0
new: 5.0
path: .spaces[0].metrics.loc.lloc
old: 251.0
new: 7.0
path: .spaces[0].metrics.mi.mi_sei
old: -41.96858228785192
new: 71.73276139437348
path: .spaces[0].metrics.mi.mi_visual_studio
old: 5.917539616211174
new: 47.21519427074715
path: .spaces[0].metrics.mi.mi_original
old: 10.118992743721108
new: 80.73798220297762
path: .spaces[0].metrics.nargs.sum
old: 2.0
new: 0.0
path: .spaces[0].metrics.nargs.average
old: 2.0
new: 0.0
Code
static char* SearchSymbolTable(SymbolTable& aTable, uint32_t aOffset) {
size_t index;
bool exact =
BinarySearch(aTable.mAddrs, 0, aTable.mAddrs.Length(), aOffset, &index);
if (index == 0 && !exact) {
// Our offset is before the first symbol in the table; no result.
return nullptr;
}
// Extract the (mangled) symbol name out of the string table.
auto strings = reinterpret_cast(aTable.mBuffer.Elements());
nsCString symbol;
symbol.Append(strings + aTable.mIndex[index - 1],
aTable.mIndex[index] - aTable.mIndex[index - 1]);
// First try demangling as a Rust identifier.
char demangled[1024];
if (!profiler_demangle_rust(symbol.get(), demangled,
ArrayLength(demangled))) {
// Then as a C++ identifier.
DemangleSymbol(symbol.get(), demangled, ArrayLength(demangled));
}
demangled[ArrayLength(demangled) - 1] = '\0';
// Use the mangled name if we didn't successfully demangle.
return strdup(demangled[0] != '\0' ? demangled : symbol.get());
}