Global Metrics
path: .metrics.loc.ploc
old: 715.0
new: 72.0
path: .metrics.loc.blank
old: 0.0
new: 18.0
path: .metrics.loc.lloc
old: 86.0
new: 26.0
path: .metrics.loc.cloc
old: 325.0
new: 10.0
path: .metrics.loc.sloc
old: 878.0
new: 100.0
path: .metrics.cognitive.average
old: 2.4
new: 0.4444444444444444
path: .metrics.cognitive.sum
old: 12.0
new: 4.0
path: .metrics.cyclomatic.average
old: 3.0
new: 1.7272727272727273
path: .metrics.cyclomatic.sum
old: 18.0
new: 19.0
path: .metrics.nom.total
old: 5.0
new: 9.0
path: .metrics.nom.functions
old: 5.0
new: 9.0
path: .metrics.mi.mi_sei
old: -24.423882747631424
new: 26.287918783891215
path: .metrics.mi.mi_original
old: 6.232445247903158
new: 53.04475246627268
path: .metrics.mi.mi_visual_studio
old: 3.644704823335181
new: 31.02032307969163
path: .metrics.halstead.N2
old: 1182.0
new: 116.0
path: .metrics.halstead.difficulty
old: 48.57534246575342
new: 22.307692307692307
path: .metrics.halstead.effort
old: 854314.3484516473
new: 40189.94224016423
path: .metrics.halstead.level
old: 0.02058657642413988
new: 0.04482758620689655
path: .metrics.halstead.N1
old: 936.0
new: 176.0
path: .metrics.halstead.n2
old: 292.0
new: 52.0
path: .metrics.halstead.length
old: 2118.0
new: 292.0
path: .metrics.halstead.volume
old: 17587.4076246391
new: 1801.618100421155
path: .metrics.halstead.n1
old: 24.0
new: 20.0
path: .metrics.halstead.vocabulary
old: 316.0
new: 72.0
path: .metrics.halstead.bugs
old: 3.0011696481268983
new: 0.3911022669860427
path: .metrics.halstead.purity_ratio
old: 1.181051874981243
new: 1.3111692713735754
path: .metrics.halstead.time
old: 47461.90824731374
new: 2232.7745688980126
path: .metrics.halstead.estimated_program_length
old: 2501.4678712102727
new: 382.861427241084
path: .metrics.nexits.sum
old: 0.0
new: 2.0
path: .metrics.nexits.average
old: 0.0
new: 0.2222222222222222
path: .metrics.nargs.average
old: 7.2
new: 0.5555555555555556
path: .metrics.nargs.sum
old: 36.0
new: 5.0
Spaces Data
Minimal test - lines (16, 100)
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 9.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 9.0
path: .spaces[0].metrics.halstead.n2
old: 94.0
new: 47.0
path: .spaces[0].metrics.halstead.n1
old: 14.0
new: 20.0
path: .spaces[0].metrics.halstead.N2
old: 185.0
new: 111.0
path: .spaces[0].metrics.halstead.volume
old: 2438.514388281012
new: 1728.835419280465
path: .spaces[0].metrics.halstead.vocabulary
old: 108.0
new: 67.0
path: .spaces[0].metrics.halstead.N1
old: 176.0
new: 174.0
path: .spaces[0].metrics.halstead.time
old: 1866.3570524964011
new: 2268.3301600488367
path: .spaces[0].metrics.halstead.level
old: 0.07258687258687259
new: 0.04234234234234235
path: .spaces[0].metrics.halstead.bugs
old: 0.347048552059426
new: 0.39524336992823594
path: .spaces[0].metrics.halstead.estimated_program_length
old: 669.4343209665043
new: 347.5042379265962
path: .spaces[0].metrics.halstead.effort
old: 33594.42694493522
new: 40829.94288087906
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.854388700738239
new: 1.2193131155319166
path: .spaces[0].metrics.halstead.length
old: 361.0
new: 285.0
path: .spaces[0].metrics.halstead.difficulty
old: 13.77659574468085
new: 23.617021276595743
path: .spaces[0].metrics.loc.blank
old: 11.0
new: 14.0
path: .spaces[0].metrics.loc.lloc
old: 11.0
new: 26.0
path: .spaces[0].metrics.loc.sloc
old: 105.0
new: 85.0
path: .spaces[0].metrics.loc.cloc
old: 8.0
new: 4.0
path: .spaces[0].metrics.loc.ploc
old: 86.0
new: 67.0
path: .spaces[0].metrics.mi.mi_original
old: 54.59029209434624
new: 56.12199252247105
path: .spaces[0].metrics.mi.mi_sei
old: 23.99515409398772
new: 23.58766958341467
path: .spaces[0].metrics.mi.mi_visual_studio
old: 31.92414742359429
new: 32.81987866811172
path: .spaces[0].metrics.cognitive.average
old: 1.0
new: 0.4444444444444444
path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 4.0
path: .spaces[0].metrics.nargs.average
old: 6.0
new: 0.5555555555555556
path: .spaces[0].metrics.nargs.sum
old: 6.0
new: 5.0
path: .spaces[0].metrics.nexits.average
old: 0.0
new: 0.2222222222222222
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.8
path: .spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 18.0
Code
namespace mozilla {
/* static */
already_AddRefed ChildProfilerController::Create(
mozilla::ipc::Endpoint&& aEndpoint) {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
RefPtr cpc = new ChildProfilerController();
cpc->Init(std::move(aEndpoint));
return cpc.forget();
}
ChildProfilerController::ChildProfilerController() {
MOZ_COUNT_CTOR(ChildProfilerController);
}
void ChildProfilerController::Init(Endpoint&& aEndpoint) {
if (NS_SUCCEEDED(
NS_NewNamedThread("ProfilerChild", getter_AddRefs(mThread)))) {
// Now that mThread has been set, run SetupProfilerChild on the thread.
mThread->Dispatch(
NewRunnableMethod&&>(
"ChildProfilerController::SetupProfilerChild", this,
&ChildProfilerController::SetupProfilerChild, std::move(aEndpoint)),
NS_DISPATCH_NORMAL);
}
}
nsCString ChildProfilerController::GrabShutdownProfileAndShutdown() {
nsCString shutdownProfile;
ShutdownAndMaybeGrabShutdownProfileFirst(&shutdownProfile);
return shutdownProfile;
}
void ChildProfilerController::Shutdown() {
ShutdownAndMaybeGrabShutdownProfileFirst(nullptr);
}
void ChildProfilerController::ShutdownAndMaybeGrabShutdownProfileFirst(
nsCString* aOutShutdownProfile) {
if (mThread) {
mThread->Dispatch(NewRunnableMethod(
"ChildProfilerController::ShutdownProfilerChild",
this, &ChildProfilerController::ShutdownProfilerChild,
aOutShutdownProfile),
NS_DISPATCH_NORMAL);
// Shut down the thread. This call will spin until all runnables (including
// the ShutdownProfilerChild runnable) have been processed.
mThread->Shutdown();
mThread = nullptr;
}
}
ChildProfilerController::~ChildProfilerController() {
MOZ_COUNT_DTOR(ChildProfilerController);
MOZ_ASSERT(!mThread,
"Please call Shutdown before destroying ChildProfilerController");
MOZ_ASSERT(!mProfilerChild);
}
void ChildProfilerController::SetupProfilerChild(
Endpoint&& aEndpoint) {
MOZ_RELEASE_ASSERT(mThread == NS_GetCurrentThread());
MOZ_ASSERT(aEndpoint.IsValid());
mProfilerChild = new ProfilerChild();
Endpoint endpoint = std::move(aEndpoint);
if (!endpoint.Bind(mProfilerChild)) {
MOZ_CRASH("Failed to bind ProfilerChild!");
}
}
void ChildProfilerController::ShutdownProfilerChild(
nsCString* aOutShutdownProfile) {
MOZ_RELEASE_ASSERT(mThread == NS_GetCurrentThread());
if (aOutShutdownProfile) {
*aOutShutdownProfile = mProfilerChild->GrabShutdownProfile();
}
mProfilerChild->Destroy();
mProfilerChild = nullptr;
}
} // namespace mozilla