Global Metrics
path: .metrics.nom.total
old: 6.0
new: 1.0
path: .metrics.nom.functions
old: 6.0
new: 1.0
path: .metrics.halstead.vocabulary
old: 102.0
new: 80.0
path: .metrics.halstead.volume
old: 3803.282444923752
new: 1207.4882661234865
path: .metrics.halstead.length
old: 570.0
new: 191.0
path: .metrics.halstead.effort
old: 133361.85196485886
new: 12121.324517624227
path: .metrics.halstead.N1
old: 354.0
new: 104.0
path: .metrics.halstead.difficulty
old: 35.064935064935064
new: 10.038461538461538
path: .metrics.halstead.level
old: 0.02851851851851852
new: 0.0996168582375479
path: .metrics.halstead.bugs
old: 0.8700946343576307
new: 0.1758917477474228
path: .metrics.halstead.N2
old: 216.0
new: 87.0
path: .metrics.halstead.estimated_program_length
old: 598.6389683778755
new: 450.0572667809774
path: .metrics.halstead.n2
old: 77.0
new: 65.0
path: .metrics.halstead.time
old: 7408.991775825492
new: 673.4069176457904
path: .metrics.halstead.purity_ratio
old: 1.0502438041717113
new: 2.356320768486792
path: .metrics.halstead.n1
old: 25.0
new: 15.0
path: .metrics.loc.sloc
old: 139.0
new: 72.0
path: .metrics.loc.cloc
old: 34.0
new: 7.0
path: .metrics.loc.blank
old: 12.0
new: 14.0
path: .metrics.loc.lloc
old: 41.0
new: 1.0
path: .metrics.loc.ploc
old: 93.0
new: 51.0
path: .metrics.mi.mi_visual_studio
old: 26.031987986965056
new: 37.36681929732517
path: .metrics.mi.mi_sei
old: 24.819225824125077
new: 40.1146249958648
path: .metrics.mi.mi_original
old: 44.51469945771025
new: 63.89726099842605
path: .metrics.nexits.sum
old: 9.0
new: 1.0
path: .metrics.nexits.average
old: 1.5
new: 1.0
path: .metrics.cognitive.average
old: 1.0
new: 0.0
path: .metrics.cognitive.sum
old: 6.0
new: 0.0
path: .metrics.cyclomatic.sum
old: 16.0
new: 4.0
path: .metrics.cyclomatic.average
old: 1.7777777777777777
new: 1.0
path: .metrics.nargs.average
old: 1.1666666666666667
new: 0.0
path: .metrics.nargs.sum
old: 7.0
new: 0.0
Spaces Data
Minimal test - lines (32, 36)
path: .spaces[0].spaces[0].metrics.loc.blank
old: 10.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 85.0
new: 5.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 41.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 23.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 118.0
new: 5.0
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 47.76095408658567
new: 120.1336842533517
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 26.22234898926158
new: 97.71723838342275
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 27.93038250677525
new: 70.2536165224279
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 6.0
new: 0.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 9.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 1.5
new: 1.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 14.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 6.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nom.functions
old: 6.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 137066.921912018
new: 619.2338627141834
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 353.0
new: 16.0
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 71.0
new: 9.0
path: .spaces[0].spaces[0].metrics.halstead.length
old: 563.0
new: 27.0
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.8861362818531208
new: 0.024216713866637193
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 3707.33388790601
new: 112.58797503894245
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 96.0
new: 18.0
path: .spaces[0].spaces[0].metrics.halstead.time
old: 7614.828995112111
new: 34.40188126189908
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 0.9817556842436956
new: 2.113283334294875
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 552.7284502292006
new: 57.05865002596162
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 25.0
new: 9.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.02704761904761905
new: 0.18181818181818185
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 210.0
new: 11.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 36.971830985915496
new: 5.5
path: .spaces[0].spaces[0].metrics.nargs.average
old: 1.1666666666666667
new: 0.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 7.0
new: 0.0
Code
static nsProfiler* GetOrCreate() {
nsCOMPtr iprofiler =
do_GetService("@mozilla.org/tools/profiler;1");
return static_cast(iprofiler.get());
}
Minimal test - lines (22, 70)
path: .spaces[0].metrics.halstead.N2
old: 211.0
new: 74.0
path: .spaces[0].metrics.halstead.vocabulary
old: 97.0
new: 68.0
path: .spaces[0].metrics.halstead.volume
old: 3728.9507558357273
new: 1077.48092290131
path: .spaces[0].metrics.halstead.purity_ratio
old: 0.9917362917667514
new: 2.046232446474448
path: .spaces[0].metrics.halstead.difficulty
old: 36.63194444444444
new: 10.471698113207546
path: .spaces[0].metrics.halstead.n1
old: 25.0
new: 15.0
path: .spaces[0].metrics.halstead.bugs
old: 0.8841171708686467
new: 0.1676859004668138
path: .spaces[0].metrics.halstead.length
old: 565.0
new: 177.0
path: .spaces[0].metrics.halstead.N1
old: 354.0
new: 103.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 560.3310048482145
new: 362.1831430259773
path: .spaces[0].metrics.halstead.level
old: 0.027298578199052133
new: 0.0954954954954955
path: .spaces[0].metrics.halstead.n2
old: 72.0
new: 53.0
path: .spaces[0].metrics.halstead.time
old: 7588.817606880194
new: 626.8363859645985
path: .spaces[0].metrics.halstead.effort
old: 136598.7169238435
new: 11283.054947362774
path: .spaces[0].metrics.nom.functions
old: 6.0
new: 1.0
path: .spaces[0].metrics.nom.total
old: 6.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.875
new: 1.0
path: .spaces[0].metrics.cyclomatic.sum
old: 15.0
new: 3.0
path: .spaces[0].metrics.nargs.average
old: 1.1666666666666667
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 7.0
new: 0.0
path: .spaces[0].metrics.nexits.average
old: 1.5
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 9.0
new: 1.0
path: .spaces[0].metrics.mi.mi_original
old: 47.22844646024636
new: 70.95412936295048
path: .spaces[0].metrics.mi.mi_visual_studio
old: 27.618974538155765
new: 41.49364290231022
path: .spaces[0].metrics.mi.mi_sei
old: 25.898181928991853
new: 37.94533384243379
path: .spaces[0].metrics.cognitive.sum
old: 6.0
new: 0.0
path: .spaces[0].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[0].metrics.loc.blank
old: 9.0
new: 11.0
path: .spaces[0].metrics.loc.sloc
old: 120.0
new: 49.0
path: .spaces[0].metrics.loc.ploc
old: 87.0
new: 37.0
path: .spaces[0].metrics.loc.lloc
old: 41.0
new: 1.0
path: .spaces[0].metrics.loc.cloc
old: 24.0
new: 1.0
Code
class nsProfiler final : public nsIProfiler, public nsIObserver {
public:
nsProfiler();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIPROFILER
nsresult Init();
static nsProfiler* GetOrCreate() {
nsCOMPtr iprofiler =
do_GetService("@mozilla.org/tools/profiler;1");
return static_cast(iprofiler.get());
}
void GatheredOOPProfile(const nsACString& aProfile);
private:
~nsProfiler();
typedef mozilla::MozPromise GatheringPromise;
typedef mozilla::MozPromise
SymbolTablePromise;
RefPtr StartGathering(double aSinceTime);
void FinishGathering();
void ResetGathering();
static void GatheringTimerCallback(nsITimer* aTimer, void* aClosure);
RefPtr GetSymbolTableMozPromise(
const nsACString& aDebugPath, const nsACString& aBreakpadID);
bool mLockedForPrivateBrowsing;
struct ExitProfile {
nsCString mJSON;
uint64_t mBufferPositionAtGatherTime;
};
// These fields are all related to profile gathering.
mozilla::Vector mExitProfiles;
mozilla::Maybe> mPromiseHolder;
nsCOMPtr mSymbolTableThread;
mozilla::Maybe mWriter;
uint32_t mPendingProfiles;
bool mGathering;
nsCOMPtr mGatheringTimer;
};