Global Metrics

path: .metrics.nom.functions
old: 17.0
new: 19.0

path: .metrics.nom.total
old: 17.0
new: 20.0

path: .metrics.nom.closures
old: 0.0
new: 1.0

path: .metrics.halstead.difficulty
old: 124.92735042735043
new: 25.89041095890411

path: .metrics.halstead.time
old: 314612.8972786872
new: 7609.342992907445

path: .metrics.halstead.N2
old: 2139.0
new: 315.0

path: .metrics.halstead.bugs
old: 10.590377233580671
new: 0.8857106273395157

path: .metrics.halstead.n1
old: 41.0
new: 24.0

path: .metrics.halstead.n2
old: 351.0
new: 146.0

path: .metrics.halstead.volume
old: 45330.60319973422
new: 5290.305128402319

path: .metrics.halstead.estimated_program_length
old: 3187.479486516242
new: 1159.7534856137902

path: .metrics.halstead.effort
old: 5663032.151016369
new: 136968.173872334

path: .metrics.halstead.length
old: 5262.0
new: 714.0

path: .metrics.halstead.vocabulary
old: 392.0
new: 170.0

path: .metrics.halstead.N1
old: 3123.0
new: 399.0

path: .metrics.halstead.level
old: 0.008004652276536791
new: 0.038624338624338624

path: .metrics.halstead.purity_ratio
old: 0.6057543683991338
new: 1.6243046016999865

path: .metrics.cyclomatic.average
old: 11.73913043478261
new: 1.238095238095238

path: .metrics.cyclomatic.sum
old: 270.0
new: 26.0

path: .metrics.loc.ploc
old: 680.0
new: 188.0

path: .metrics.loc.blank
old: 32.0
new: 42.0

path: .metrics.loc.sloc
old: 760.0
new: 285.0

path: .metrics.loc.cloc
old: 48.0
new: 55.0

path: .metrics.loc.lloc
old: 509.0
new: 42.0

path: .metrics.mi.mi_sei
old: -107.58779179919284
new: 0.053747055693825985

path: .metrics.mi.mi_original
old: -54.312794402788846
new: 28.866793021883694

path: .metrics.mi.mi_visual_studio
old: 0.0
new: 16.881165509873505

path: .metrics.nargs.sum
old: 48.0
new: 17.0

path: .metrics.nargs.average
old: 2.823529411764706
new: 0.85

path: .metrics.nexits.sum
old: 100.0
new: 8.0

path: .metrics.nexits.average
old: 5.882352941176471
new: 0.4

path: .metrics.cognitive.average
old: 13.823529411764708
new: 0.35

path: .metrics.cognitive.sum
old: 235.0
new: 7.0

Spaces Data

Minimal test - lines (261, 284)

path: .spaces[15].metrics.nexits.average
old: 4.0
new: 0.0

path: .spaces[15].metrics.nexits.sum
old: 4.0
new: 0.0

path: .spaces[15].metrics.nargs.sum
old: 2.0
new: 0.0

path: .spaces[15].metrics.nargs.average
old: 2.0
new: 0.0

path: .spaces[15].metrics.cyclomatic.average
old: 6.0
new: 1.0

path: .spaces[15].metrics.cyclomatic.sum
old: 6.0
new: 1.0

path: .spaces[15].metrics.cognitive.average
old: 7.0
new: 0.0

path: .spaces[15].metrics.cognitive.sum
old: 7.0
new: 0.0

path: .spaces[15].metrics.loc.blank
old: 1.0
new: 0.0

path: .spaces[15].metrics.loc.lloc
old: 15.0
new: 4.0

path: .spaces[15].metrics.loc.sloc
old: 23.0
new: 24.0

path: .spaces[15].metrics.loc.ploc
old: 22.0
new: 18.0

path: .spaces[15].metrics.loc.cloc
old: 0.0
new: 6.0

path: .spaces[15].metrics.halstead.effort
old: 12377.231819113047
new: 1735.9892774096904

path: .spaces[15].metrics.halstead.time
old: 687.6239899507249
new: 96.4438487449828

path: .spaces[15].metrics.halstead.length
old: 119.0
new: 52.0

path: .spaces[15].metrics.halstead.volume
old: 605.4080781087904
new: 249.9824559469954

path: .spaces[15].metrics.halstead.n1
old: 16.0
new: 10.0

path: .spaces[15].metrics.halstead.N1
old: 73.0
new: 27.0

path: .spaces[15].metrics.halstead.difficulty
old: 20.444444444444443
new: 6.944444444444445

path: .spaces[15].metrics.halstead.bugs
old: 0.178358753571657
new: 0.0481478358096778

path: .spaces[15].metrics.halstead.purity_ratio
old: 1.1685600842517785
new: 2.082267903362216

path: .spaces[15].metrics.halstead.estimated_program_length
old: 139.0586500259616
new: 108.27793097483524

path: .spaces[15].metrics.halstead.vocabulary
old: 34.0
new: 28.0

path: .spaces[15].metrics.halstead.level
old: 0.04891304347826087
new: 0.144

path: .spaces[15].metrics.halstead.N2
old: 46.0
new: 25.0

path: .spaces[15].metrics.mi.mi_visual_studio
old: 50.00836225400652
new: 52.96742462256545

path: .spaces[15].metrics.mi.mi_original
old: 85.51429945435115
new: 90.57429610458692

path: .spaces[15].metrics.mi.mi_sei
old: 48.28112291230019
new: 90.04344921266029

Code

void Registers::SyncPopulate() {
#  if defined(__x86_64__)
  asm(
      // Compute caller's %rsp by adding to %rbp:
      // 8 bytes for previous %rbp, 8 bytes for return address
      "leaq 0x10(%%rbp), %0\n\t"
      // Dereference %rbp to get previous %rbp
      "movq (%%rbp), %1\n\t"
      : "=r"(mSP), "=r"(mFP));
#  elif defined(__aarch64__)
  asm(
      // Compute caller's sp by adding to fp:
      // 8 bytes for previous fp, 8 bytes for return address
      "add %0, x29, #0x10\n\t"
      // Dereference fp to get previous fp
      "ldr %1, [x29]\n\t"
      : "=r"(mSP), "=r"(mFP));
#  else
#    error "unknown architecture"
#  endif
  mPC = reinterpret_cast
( __builtin_extract_return_addr(__builtin_return_address(0))); mLR = 0; }

Minimal test - lines (245, 251)

path: .spaces[12].metrics.loc.lloc
old: 5.0
new: 1.0

path: .spaces[12].metrics.loc.sloc
old: 14.0
new: 7.0

path: .spaces[12].metrics.loc.ploc
old: 12.0
new: 3.0

path: .spaces[12].metrics.loc.cloc
old: 2.0
new: 4.0

path: .spaces[12].metrics.halstead.N2
old: 31.0
new: 4.0

path: .spaces[12].metrics.halstead.bugs
old: 0.11109575175882094
new: 0.007652568082218515

path: .spaces[12].metrics.halstead.length
old: 80.0
new: 11.0

path: .spaces[12].metrics.halstead.difficulty
old: 15.5
new: 3.3333333333333335

path: .spaces[12].metrics.halstead.vocabulary
old: 30.0
new: 8.0

path: .spaces[12].metrics.halstead.n1
old: 15.0
new: 5.0

path: .spaces[12].metrics.halstead.estimated_program_length
old: 117.20671786825557
new: 16.36452797660028

path: .spaces[12].metrics.halstead.n2
old: 15.0
new: 3.0

path: .spaces[12].metrics.halstead.N1
old: 49.0
new: 7.0

path: .spaces[12].metrics.halstead.effort
old: 6084.544338554563
new: 110.0

path: .spaces[12].metrics.halstead.time
old: 338.03024103080907
new: 6.111111111111111

path: .spaces[12].metrics.halstead.purity_ratio
old: 1.4650839733531946
new: 1.4876843615091162

path: .spaces[12].metrics.halstead.volume
old: 392.5512476486815
new: 33.0

path: .spaces[12].metrics.halstead.level
old: 0.06451612903225806
new: 0.3

path: .spaces[12].metrics.mi.mi_visual_studio
old: 56.163393193716935
new: 70.79790424893464

path: .spaces[12].metrics.mi.mi_original
old: 96.03940236125597
new: 121.06441626567825

path: .spaces[12].metrics.mi.mi_sei
old: 90.9962939616256
new: 145.11857376988775

path: .spaces[12].metrics.nexits.average
old: 2.0
new: 0.0

path: .spaces[12].metrics.nexits.sum
old: 2.0
new: 0.0

path: .spaces[12].metrics.cognitive.average
old: 4.0
new: 0.0

path: .spaces[12].metrics.cognitive.sum
old: 4.0
new: 0.0

path: .spaces[12].metrics.cyclomatic.average
old: 5.0
new: 1.0

path: .spaces[12].metrics.cyclomatic.sum
old: 5.0
new: 1.0

path: .spaces[12].metrics.nargs.average
old: 3.0
new: 1.0

path: .spaces[12].metrics.nargs.sum
old: 3.0
new: 1.0

Code

void SamplerThread::SleepMicro(uint32_t aMicroseconds) {
  usleep(aMicroseconds);
  // FIXME: the OSX 10.12 page for usleep says "The usleep() function is
  // obsolescent.  Use nanosleep(2) instead."  This implementation could be
  // merged with the linux-android version.  Also, this doesn't handle the
  // case where the usleep call is interrupted by a signal.
}

Minimal test - lines (94, 128)

path: .spaces[7].metrics.mi.mi_original
old: 19.466671322483933
new: 77.09747268442048

path: .spaces[7].metrics.mi.mi_sei
old: -38.04531502843038
new: 35.832749093086406

path: .spaces[7].metrics.mi.mi_visual_studio
old: 11.384018317242068
new: 45.08624133591841

path: .spaces[7].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[7].metrics.loc.sloc
old: 148.0
new: 35.0

path: .spaces[7].metrics.loc.ploc
old: 148.0
new: 32.0

path: .spaces[7].metrics.loc.blank
old: 0.0
new: 3.0

path: .spaces[7].metrics.loc.lloc
old: 140.0
new: 8.0

path: .spaces[7].metrics.halstead.length
old: 1672.0
new: 161.0

path: .spaces[7].metrics.halstead.level
old: 0.009281259281259282
new: 0.05507246376811594

path: .spaces[7].metrics.halstead.N2
old: 728.0
new: 69.0

path: .spaces[7].metrics.halstead.difficulty
old: 107.744
new: 18.157894736842103

path: .spaces[7].metrics.halstead.effort
old: 1322259.063444459
new: 17125.34496707163

path: .spaces[7].metrics.halstead.purity_ratio
old: 0.6360483314061196
new: 1.775526754090705

path: .spaces[7].metrics.halstead.vocabulary
old: 162.0
new: 58.0

path: .spaces[7].metrics.halstead.volume
old: 12272.229204823092
new: 943.134940215539

path: .spaces[7].metrics.halstead.estimated_program_length
old: 1063.472810111032
new: 285.8598074086035

path: .spaces[7].metrics.halstead.N1
old: 944.0
new: 92.0

path: .spaces[7].metrics.halstead.bugs
old: 4.015655491259494
new: 0.221464930431118

path: .spaces[7].metrics.halstead.n2
old: 125.0
new: 38.0

path: .spaces[7].metrics.halstead.n1
old: 37.0
new: 20.0

path: .spaces[7].metrics.halstead.time
old: 73458.8368580255
new: 951.4080537262016

path: .spaces[7].metrics.cyclomatic.average
old: 94.0
new: 3.0

path: .spaces[7].metrics.cyclomatic.sum
old: 94.0
new: 3.0

path: .spaces[7].metrics.nexits.sum
old: 47.0
new: 1.0

path: .spaces[7].metrics.nexits.average
old: 47.0
new: 0.5

path: .spaces[7].metrics.nom.closures
old: 0.0
new: 1.0

path: .spaces[7].metrics.nom.total
old: 1.0
new: 2.0

path: .spaces[7].metrics.cognitive.average
old: 71.0
new: 2.0

path: .spaces[7].metrics.cognitive.sum
old: 71.0
new: 4.0

Code

static RunningTimes GetThreadRunningTimesDiff(
    PSLockRef aLock, const RegisteredThread& aRegisteredThread) {
  AUTO_PROFILER_STATS(GetRunningTimes);

  PlatformData* platformData = aRegisteredThread.GetPlatformData();
  MOZ_RELEASE_ASSERT(platformData);

  const RunningTimes newRunningTimes = GetRunningTimesWithTightTimestamp(
      [platformData](RunningTimes& aRunningTimes) {
        AUTO_PROFILER_STATS(GetRunningTimes_thread_info);
        thread_basic_info_data_t threadBasicInfo;
        mach_msg_type_number_t basicCount = THREAD_BASIC_INFO_COUNT;
        if (thread_info(platformData->ProfiledThread(), THREAD_BASIC_INFO,
                        reinterpret_cast(&threadBasicInfo),
                        &basicCount) == KERN_SUCCESS &&
            basicCount == THREAD_BASIC_INFO_COUNT) {
          uint64_t userTimeUs =
              uint64_t(threadBasicInfo.user_time.seconds) *
                  uint64_t(USEC_PER_SEC) +
              uint64_t(threadBasicInfo.user_time.microseconds);
          uint64_t systemTimeUs =
              uint64_t(threadBasicInfo.system_time.seconds) *
                  uint64_t(USEC_PER_SEC) +
              uint64_t(threadBasicInfo.system_time.microseconds);
          aRunningTimes.ResetThreadCPUDelta(userTimeUs + systemTimeUs);
        } else {
          aRunningTimes.ClearThreadCPUDelta();
        }
      });

  const RunningTimes diff =
      newRunningTimes - platformData->PreviousThreadRunningTimesRef();
  platformData->PreviousThreadRunningTimesRef() = newRunningTimes;
  return diff;
}

Minimal test - lines (224, 235)

path: .spaces[10].metrics.halstead.time
old: 267.473216930497
new: 153.23085376378523

path: .spaces[10].metrics.halstead.purity_ratio
old: 1.3806858537043647
new: 2.2494340299362268

path: .spaces[10].metrics.halstead.vocabulary
old: 25.0
new: 35.0

path: .spaces[10].metrics.halstead.effort
old: 4814.517904748946
new: 2758.1553677481343

path: .spaces[10].metrics.halstead.length
old: 66.0
new: 65.0

path: .spaces[10].metrics.halstead.volume
old: 306.49450852513183
new: 333.4033961014228

path: .spaces[10].metrics.halstead.N2
old: 29.0
new: 28.0

path: .spaces[10].metrics.halstead.n2
old: 12.0
new: 22.0

path: .spaces[10].metrics.halstead.level
old: 0.0636604774535809
new: 0.12087912087912088

path: .spaces[10].metrics.halstead.difficulty
old: 15.708333333333334
new: 8.272727272727273

path: .spaces[10].metrics.halstead.estimated_program_length
old: 91.12526634448808
new: 146.21321194585474

path: .spaces[10].metrics.halstead.bugs
old: 0.09504164605456336
new: 0.06555782896998709

path: .spaces[10].metrics.nexits.average
old: 2.0
new: 0.0

path: .spaces[10].metrics.nexits.sum
old: 2.0
new: 0.0

path: .spaces[10].metrics.mi.mi_sei
old: 71.54667721958054
new: 68.88175754187148

path: .spaces[10].metrics.mi.mi_visual_studio
old: 59.60412714648633
new: 58.52390401138531

path: .spaces[10].metrics.mi.mi_original
old: 101.92305742049165
new: 100.07587585946888

path: .spaces[10].metrics.loc.ploc
old: 11.0
new: 12.0

path: .spaces[10].metrics.loc.lloc
old: 7.0
new: 2.0

path: .spaces[10].metrics.loc.sloc
old: 11.0
new: 12.0

path: .spaces[10].metrics.nargs.average
old: 0.0
new: 3.0

path: .spaces[10].metrics.nargs.sum
old: 0.0
new: 3.0

Code

SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
                             double aIntervalMilliseconds)
    : mSampler(aLock),
      mActivityGeneration(aActivityGeneration),
      mIntervalMicroseconds(
          std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5)))),
      mThread{nullptr} {
  pthread_attr_t* attr_ptr = nullptr;
  if (pthread_create(&mThread, attr_ptr, ThreadEntry, this) != 0) {
    MOZ_CRASH("pthread_create failed");
  }
}

Minimal test - lines (258, 258)

path: .spaces[14].metrics.halstead.vocabulary
old: 40.0
new: 6.0

path: .spaces[14].metrics.halstead.effort
old: 18898.166664945027
new: 23.264662506490403

path: .spaces[14].metrics.halstead.bugs
old: 0.23649675990721164
new: 0.0027165012951989257

path: .spaces[14].metrics.halstead.length
old: 134.0
new: 6.0

path: .spaces[14].metrics.halstead.volume
old: 713.1383647149066
new: 15.509775004326936

path: .spaces[14].metrics.halstead.N1
old: 81.0
new: 3.0

path: .spaces[14].metrics.halstead.difficulty
old: 26.5
new: 1.5

path: .spaces[14].metrics.halstead.time
old: 1049.8981480525017
new: 1.292481250360578

path: .spaces[14].metrics.halstead.level
old: 0.03773584905660377
new: 0.6666666666666666

path: .spaces[14].metrics.halstead.n1
old: 20.0
new: 3.0

path: .spaces[14].metrics.halstead.N2
old: 53.0
new: 3.0

path: .spaces[14].metrics.halstead.purity_ratio
old: 1.2901277895186156
new: 1.584962500721156

path: .spaces[14].metrics.halstead.n2
old: 20.0
new: 3.0

path: .spaces[14].metrics.halstead.estimated_program_length
old: 172.8771237954945
new: 9.509775004326936

path: .spaces[14].metrics.cognitive.average
old: 7.0
new: 0.0

path: .spaces[14].metrics.cognitive.sum
old: 7.0
new: 0.0

path: .spaces[14].metrics.loc.lloc
old: 14.0
new: 0.0

path: .spaces[14].metrics.loc.sloc
old: 23.0
new: 1.0

path: .spaces[14].metrics.loc.ploc
old: 23.0
new: 1.0

path: .spaces[14].metrics.mi.mi_original
old: 84.43268130216956
new: 156.51435355291963

path: .spaces[14].metrics.mi.mi_sei
old: 46.822497627416794
new: 150.2034495661308

path: .spaces[14].metrics.mi.mi_visual_studio
old: 49.37583701881261
new: 91.5288617268536

path: .spaces[14].metrics.cyclomatic.average
old: 7.0
new: 1.0

path: .spaces[14].metrics.cyclomatic.sum
old: 7.0
new: 1.0

path: .spaces[14].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[14].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[14].metrics.nexits.average
old: 4.0
new: 0.0

path: .spaces[14].metrics.nexits.sum
old: 4.0
new: 0.0

Code

static void PlatformInit(PSLockRef aLock) {}

Minimal test - lines (237, 243)

path: .spaces[11].metrics.halstead.n1
old: 13.0
new: 6.0

path: .spaces[11].metrics.halstead.difficulty
old: 13.0
new: 3.0

path: .spaces[11].metrics.halstead.n2
old: 9.0
new: 8.0

path: .spaces[11].metrics.halstead.time
old: 157.81433005955327
new: 13.325742227201616

path: .spaces[11].metrics.halstead.length
old: 49.0
new: 21.0

path: .spaces[11].metrics.halstead.level
old: 0.07692307692307693
new: 0.3333333333333333

path: .spaces[11].metrics.halstead.volume
old: 218.5121493132276
new: 79.9544533632097

path: .spaces[11].metrics.halstead.estimated_program_length
old: 76.63504134881501
new: 39.50977500432694

path: .spaces[11].metrics.halstead.effort
old: 2840.6579410719587
new: 239.86336008962908

path: .spaces[11].metrics.halstead.N1
old: 31.0
new: 13.0

path: .spaces[11].metrics.halstead.N2
old: 18.0
new: 8.0

path: .spaces[11].metrics.halstead.vocabulary
old: 22.0
new: 14.0

path: .spaces[11].metrics.halstead.purity_ratio
old: 1.563980435690102
new: 1.881417857348902

path: .spaces[11].metrics.halstead.bugs
old: 0.06685871715725097
new: 0.0128683052427308

path: .spaces[11].metrics.loc.cloc
old: 0.0
new: 2.0

path: .spaces[11].metrics.loc.ploc
old: 6.0
new: 5.0

path: .spaces[11].metrics.loc.lloc
old: 3.0
new: 2.0

path: .spaces[11].metrics.loc.sloc
old: 6.0
new: 7.0

path: .spaces[11].metrics.mi.mi_sei
old: 88.48144512203254
new: 129.25276411166192

path: .spaces[11].metrics.mi.mi_visual_studio
old: 66.50989485028335
new: 68.10682950846503

path: .spaces[11].metrics.mi.mi_original
old: 113.73192019398452
new: 116.4626784594752

path: .spaces[11].metrics.nargs.average
old: 3.0
new: 0.0

path: .spaces[11].metrics.nargs.sum
old: 3.0
new: 0.0

path: .spaces[11].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[11].metrics.nexits.average
old: 1.0
new: 0.0

Code

SamplerThread::~SamplerThread() {
  pthread_join(mThread, nullptr);
  // Just in the unlikely case some callbacks were added between the end of the
  // thread and now.
  InvokePostSamplingCallbacks(std::move(mPostSamplingCallbackList),
                              SamplingState::JustStopped);
}

Minimal test - lines (54, 79)

path: .spaces[3].metrics.mi.mi_visual_studio
old: 43.127638219674864
new: 51.784800109691226

path: .spaces[3].metrics.mi.mi_sei
old: 56.00360058833045
new: 81.10851385131681

path: .spaces[3].metrics.mi.mi_original
old: 73.74826135564402
new: 88.552008187572

path: .spaces[3].metrics.cyclomatic.average
old: 12.0
new: 1.0

path: .spaces[3].metrics.cyclomatic.sum
old: 12.0
new: 5.0

path: .spaces[3].metrics.nexits.average
old: 1.0
new: 0.5

path: .spaces[3].metrics.nexits.sum
old: 1.0
new: 2.0

path: .spaces[3].metrics.halstead.length
old: 171.0
new: 54.0

path: .spaces[3].metrics.halstead.volume
old: 933.5628067869778
new: 240.8093074064141

path: .spaces[3].metrics.halstead.N1
old: 112.0
new: 31.0

path: .spaces[3].metrics.halstead.estimated_program_length
old: 196.477661915055
new: 76.63504134881501

path: .spaces[3].metrics.halstead.n1
old: 24.0
new: 9.0

path: .spaces[3].metrics.halstead.N2
old: 59.0
new: 23.0

path: .spaces[3].metrics.halstead.bugs
old: 0.34327587329635945
new: 0.05144291731560698

path: .spaces[3].metrics.halstead.time
old: 1836.006853347723
new: 106.51180904514467

path: .spaces[3].metrics.halstead.vocabulary
old: 44.0
new: 22.0

path: .spaces[3].metrics.halstead.difficulty
old: 35.4
new: 7.961538461538462

path: .spaces[3].metrics.halstead.n2
old: 20.0
new: 13.0

path: .spaces[3].metrics.halstead.purity_ratio
old: 1.148992174941842
new: 1.419167432385463

path: .spaces[3].metrics.halstead.level
old: 0.02824858757062147
new: 0.12560386473429952

path: .spaces[3].metrics.halstead.effort
old: 33048.123360259015
new: 1917.2125628126043

path: .spaces[3].metrics.cognitive.average
old: 19.0
new: 0.0

path: .spaces[3].metrics.cognitive.sum
old: 19.0
new: 0.0

path: .spaces[3].metrics.loc.ploc
old: 33.0
new: 17.0

path: .spaces[3].metrics.loc.sloc
old: 38.0
new: 26.0

path: .spaces[3].metrics.loc.blank
old: 1.0
new: 5.0

path: .spaces[3].metrics.loc.lloc
old: 20.0
new: 5.0

path: .spaces[3].metrics.nom.functions
old: 1.0
new: 4.0

path: .spaces[3].metrics.nom.total
old: 1.0
new: 4.0

path: .spaces[3].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[3].metrics.nargs.average
old: 2.0
new: 0.25

Code

class PlatformData {
 public:
  explicit PlatformData(int aThreadId) : mProfiledThread(mach_thread_self()) {
    MOZ_COUNT_CTOR(PlatformData);
  }

  ~PlatformData() {
    // Deallocate Mach port for thread.
    mach_port_deallocate(mach_task_self(), mProfiledThread);

    MOZ_COUNT_DTOR(PlatformData);
  }

  thread_act_t ProfiledThread() const { return mProfiledThread; }

  RunningTimes& PreviousThreadRunningTimesRef() {
    return mPreviousThreadRunningTimes;
  }

 private:
  // Note: for mProfiledThread Mach primitives are used instead of pthread's
  // because the latter doesn't provide thread manipulation primitives required.
  // For details, consult "Mac OS X Internals" book, Section 7.3.
  thread_act_t mProfiledThread;
  RunningTimes mPreviousThreadRunningTimes;
};

Minimal test - lines (86, 86)

path: .spaces[5].metrics.mi.mi_visual_studio
old: 50.821592958879606
new: 90.80912574437468

path: .spaces[5].metrics.mi.mi_sei
old: 66.85626099883578
new: 148.4278547652622

path: .spaces[5].metrics.mi.mi_original
old: 86.90492395968413
new: 155.2836050228807

path: .spaces[5].metrics.nom.functions
old: 0.0
new: 1.0

path: .spaces[5].metrics.nom.total
old: 0.0
new: 1.0

path: .spaces[5].metrics.halstead.length
old: 143.0
new: 7.0

path: .spaces[5].metrics.halstead.bugs
old: 0.0700285416423818
new: 0.0038532659414573967

path: .spaces[5].metrics.halstead.time
old: 169.16947450155493
new: 2.1834982727114696

path: .spaces[5].metrics.halstead.N1
old: 86.0
new: 4.0

path: .spaces[5].metrics.halstead.n2
old: 56.0
new: 3.0

path: .spaces[5].metrics.halstead.vocabulary
old: 63.0
new: 7.0

path: .spaces[5].metrics.halstead.level
old: 0.2807017543859649
new: 0.5

path: .spaces[5].metrics.halstead.estimated_program_length
old: 344.863360089629
new: 12.754887502163468

path: .spaces[5].metrics.halstead.n1
old: 7.0
new: 4.0

path: .spaces[5].metrics.halstead.volume
old: 854.7510290604881
new: 19.651484454403228

path: .spaces[5].metrics.halstead.effort
old: 3045.050541027989
new: 39.302968908806456

path: .spaces[5].metrics.halstead.N2
old: 57.0
new: 3.0

path: .spaces[5].metrics.halstead.purity_ratio
old: 2.4116318887386643
new: 1.8221267860233523

path: .spaces[5].metrics.halstead.difficulty
old: 3.5625
new: 2.0

path: .spaces[5].metrics.cognitive.average
old: null
new: 0.0

path: .spaces[5].metrics.loc.cloc
old: 1.0
new: 0.0

path: .spaces[5].metrics.loc.ploc
old: 20.0
new: 1.0

path: .spaces[5].metrics.loc.sloc
old: 20.0
new: 1.0

path: .spaces[5].metrics.nexits.average
old: null
new: 0.0

path: .spaces[5].metrics.nargs.sum
old: 0.0
new: 1.0

path: .spaces[5].metrics.nargs.average
old: null
new: 1.0

path: .spaces[5].metrics.cyclomatic.sum
old: 2.0
new: 1.0

Code

void Sampler::Disable(PSLockRef aLock) {}

Minimal test - lines (218, 222)

path: .spaces[9].metrics.mi.mi_original
old: 25.08608197717456
new: 120.43379670500238

path: .spaces[9].metrics.mi.mi_sei
old: -15.09652640779277
new: 98.15020912912824

path: .spaces[9].metrics.mi.mi_visual_studio
old: 14.670223378464652
new: 70.42912088011836

path: .spaces[9].metrics.nexits.average
old: 14.0
new: 1.0

path: .spaces[9].metrics.nexits.sum
old: 14.0
new: 1.0

path: .spaces[9].metrics.cyclomatic.sum
old: 71.0
new: 1.0

path: .spaces[9].metrics.cyclomatic.average
old: 71.0
new: 1.0

path: .spaces[9].metrics.loc.cloc
old: 8.0
new: 0.0

path: .spaces[9].metrics.loc.lloc
old: 171.0
new: 2.0

path: .spaces[9].metrics.loc.ploc
old: 146.0
new: 5.0

path: .spaces[9].metrics.loc.sloc
old: 156.0
new: 5.0

path: .spaces[9].metrics.loc.blank
old: 2.0
new: 0.0

path: .spaces[9].metrics.halstead.N1
old: 752.0
new: 17.0

path: .spaces[9].metrics.halstead.difficulty
old: 43.163333333333334
new: 6.428571428571429

path: .spaces[9].metrics.halstead.N2
old: 563.0
new: 9.0

path: .spaces[9].metrics.halstead.bugs
old: 1.8753344661648923
new: 0.02585670445774269

path: .spaces[9].metrics.halstead.effort
old: 421987.8873645445
new: 683.1902177518425

path: .spaces[9].metrics.halstead.n1
old: 23.0
new: 10.0

path: .spaces[9].metrics.halstead.n2
old: 150.0
new: 7.0

path: .spaces[9].metrics.halstead.vocabulary
old: 173.0
new: 17.0

path: .spaces[9].metrics.halstead.time
old: 23443.77152025247
new: 37.955012097324584

path: .spaces[9].metrics.halstead.level
old: 0.02316781218626921
new: 0.15555555555555556

path: .spaces[9].metrics.halstead.length
old: 1315.0
new: 26.0

path: .spaces[9].metrics.halstead.estimated_program_length
old: 1188.3647285636937
new: 52.87076540327685

path: .spaces[9].metrics.halstead.volume
old: 9776.536119342292
new: 106.27403387250882

path: .spaces[9].metrics.halstead.purity_ratio
old: 0.9036994133564208
new: 2.0334909770491096

path: .spaces[9].metrics.cognitive.average
old: 81.0
new: 0.0

path: .spaces[9].metrics.cognitive.sum
old: 81.0
new: 0.0

path: .spaces[9].metrics.nargs.sum
old: 2.0
new: 0.0

path: .spaces[9].metrics.nargs.average
old: 2.0
new: 0.0

Code

static void* ThreadEntry(void* aArg) {
  auto thread = static_cast(aArg);
  thread->Run();
  return nullptr;
}

Minimal test - lines (39, 47)

path: .spaces[1].metrics.mi.mi_original
old: 127.78516612790406
new: 112.14948064002309

path: .spaces[1].metrics.mi.mi_visual_studio
old: 74.7281673262597
new: 65.58449160235267

path: .spaces[1].metrics.mi.mi_sei
old: 108.75599333929124
new: 129.13520961530776

path: .spaces[1].metrics.halstead.n2
old: 3.0
new: 5.0

path: .spaces[1].metrics.halstead.vocabulary
old: 6.0
new: 14.0

path: .spaces[1].metrics.halstead.level
old: 0.6666666666666666
new: 0.15873015873015872

path: .spaces[1].metrics.halstead.n1
old: 3.0
new: 9.0

path: .spaces[1].metrics.halstead.time
old: 2.1541354172676304
new: 29.31663289984355

path: .spaces[1].metrics.halstead.N1
old: 7.0
new: 15.0

path: .spaces[1].metrics.halstead.difficulty
old: 1.5
new: 6.3

path: .spaces[1].metrics.halstead.estimated_program_length
old: 9.509775004326936
new: 40.13896548741762

path: .spaces[1].metrics.halstead.effort
old: 38.77443751081734
new: 527.6993921971839

path: .spaces[1].metrics.halstead.purity_ratio
old: 0.9509775004326936
new: 1.8244984312462555

path: .spaces[1].metrics.halstead.length
old: 10.0
new: 22.0

path: .spaces[1].metrics.halstead.N2
old: 3.0
new: 7.0

path: .spaces[1].metrics.halstead.volume
old: 25.84962500721156
new: 83.76180828526729

path: .spaces[1].metrics.halstead.bugs
old: 0.00381864321284214
new: 0.021767228750077

path: .spaces[1].metrics.loc.lloc
old: 0.0
new: 2.0

path: .spaces[1].metrics.loc.cloc
old: 0.0
new: 4.0

path: .spaces[1].metrics.loc.sloc
old: 5.0
new: 9.0

path: .spaces[1].metrics.nexits.average
old: null
new: 1.0

path: .spaces[1].metrics.nexits.sum
old: 0.0
new: 1.0

path: .spaces[1].metrics.nargs.average
old: null
new: 0.0

path: .spaces[1].metrics.nom.functions
old: 0.0
new: 1.0

path: .spaces[1].metrics.nom.total
old: 0.0
new: 1.0

path: .spaces[1].metrics.cognitive.average
old: null
new: 0.0

Code

int profiler_current_thread_id() {
  uint64_t tid;
  pthread_threadid_np(nullptr, &tid);
  // Cast the uint64_t value to an int.
  // In theory, this risks truncating the value. It's unknown if such large
  // values occur in reality.
  // It may be worth changing our cross-platform tid type to 64 bits.
  return static_cast(tid);
}

Minimal test - lines (253, 253)

path: .spaces[13].metrics.cyclomatic.sum
old: 7.0
new: 1.0

path: .spaces[13].metrics.cyclomatic.average
old: 7.0
new: 1.0

path: .spaces[13].metrics.halstead.bugs
old: 0.27780870585043893
new: 0.00990176194569736

path: .spaces[13].metrics.halstead.n2
old: 22.0
new: 5.0

path: .spaces[13].metrics.halstead.N1
old: 95.0
new: 7.0

path: .spaces[13].metrics.halstead.vocabulary
old: 41.0
new: 11.0

path: .spaces[13].metrics.halstead.purity_ratio
old: 1.117613239784054
new: 2.0861088829818266

path: .spaces[13].metrics.halstead.N2
old: 65.0
new: 6.0

path: .spaces[13].metrics.halstead.volume
old: 857.2083207388935
new: 44.97261104228487

path: .spaces[13].metrics.halstead.effort
old: 24060.279002557578
new: 161.90139975222553

path: .spaces[13].metrics.halstead.estimated_program_length
old: 178.81811836544864
new: 27.11941547876375

path: .spaces[13].metrics.halstead.n1
old: 19.0
new: 6.0

path: .spaces[13].metrics.halstead.level
old: 0.035627530364372474
new: 0.2777777777777778

path: .spaces[13].metrics.halstead.time
old: 1336.6821668087543
new: 8.994522208456974

path: .spaces[13].metrics.halstead.difficulty
old: 28.068181818181817
new: 3.6

path: .spaces[13].metrics.halstead.length
old: 160.0
new: 13.0

path: .spaces[13].metrics.nexits.average
old: 4.0
new: 0.0

path: .spaces[13].metrics.nexits.sum
old: 4.0
new: 0.0

path: .spaces[13].metrics.mi.mi_visual_studio
old: 47.654792419763574
new: 88.2915327268843

path: .spaces[13].metrics.mi.mi_sei
old: 42.57666593840038
new: 142.21693134142208

path: .spaces[13].metrics.mi.mi_original
old: 81.48969503779571
new: 150.97852096297217

path: .spaces[13].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[13].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[13].metrics.cognitive.sum
old: 9.0
new: 0.0

path: .spaces[13].metrics.cognitive.average
old: 9.0
new: 0.0

path: .spaces[13].metrics.loc.sloc
old: 26.0
new: 1.0

path: .spaces[13].metrics.loc.lloc
old: 19.0
new: 1.0

path: .spaces[13].metrics.loc.blank
old: 1.0
new: 0.0

path: .spaces[13].metrics.loc.ploc
old: 25.0
new: 1.0

Code

void SamplerThread::Stop(PSLockRef aLock) { mSampler.Disable(aLock); }

Minimal test - lines (131, 210)

path: .spaces[8].metrics.cyclomatic.sum
old: 2.0
new: 3.0

path: .spaces[8].metrics.cyclomatic.average
old: 2.0
new: 3.0

path: .spaces[8].metrics.halstead.difficulty
old: 12.833333333333334
new: 18.947916666666668

path: .spaces[8].metrics.halstead.N1
old: 28.0
new: 112.0

path: .spaces[8].metrics.halstead.vocabulary
old: 20.0
new: 65.0

path: .spaces[8].metrics.halstead.estimated_program_length
old: 66.58307281799108
new: 337.5650683358713

path: .spaces[8].metrics.halstead.length
old: 49.0
new: 219.0

path: .spaces[8].metrics.halstead.purity_ratio
old: 1.3588382207753282
new: 1.5413930060998688

path: .spaces[8].metrics.halstead.effort
old: 2717.772450335003
new: 24990.37983714405

path: .spaces[8].metrics.halstead.bugs
old: 0.06491635699571512
new: 0.2849228742136969

path: .spaces[8].metrics.halstead.volume
old: 211.77447664948076
new: 1318.8985510532316

path: .spaces[8].metrics.halstead.time
old: 150.98735835194464
new: 1388.3544353968914

path: .spaces[8].metrics.halstead.N2
old: 21.0
new: 107.0

path: .spaces[8].metrics.halstead.n1
old: 11.0
new: 17.0

path: .spaces[8].metrics.halstead.n2
old: 9.0
new: 48.0

path: .spaces[8].metrics.halstead.level
old: 0.07792207792207792
new: 0.05277625068719076

path: .spaces[8].metrics.loc.blank
old: 0.0
new: 10.0

path: .spaces[8].metrics.loc.lloc
old: 7.0
new: 12.0

path: .spaces[8].metrics.loc.ploc
old: 9.0
new: 50.0

path: .spaces[8].metrics.loc.sloc
old: 9.0
new: 80.0

path: .spaces[8].metrics.loc.cloc
old: 0.0
new: 20.0

path: .spaces[8].metrics.nargs.sum
old: 1.0
new: 4.0

path: .spaces[8].metrics.nargs.average
old: 1.0
new: 4.0

path: .spaces[8].metrics.mi.mi_sei
old: 79.0100134238552
new: 48.967545398479274

path: .spaces[8].metrics.mi.mi_original
old: 107.09624786805558
new: 61.96149688989344

path: .spaces[8].metrics.mi.mi_visual_studio
old: 62.629384718161155
new: 36.23479350286166

path: .spaces[8].metrics.cognitive.average
old: 1.0
new: 2.0

path: .spaces[8].metrics.cognitive.sum
old: 1.0
new: 2.0

Code

void Sampler::SuspendAndSampleAndResumeThread(
    PSLockRef aLock, const RegisteredThread& aRegisteredThread,
    const TimeStamp& aNow, const Func& aProcessRegs) {
  thread_act_t samplee_thread =
      aRegisteredThread.GetPlatformData()->ProfiledThread();

  //----------------------------------------------------------------//
  // Suspend the samplee thread and get its context.

  // We're using thread_suspend on OS X because pthread_kill (which is what we
  // at one time used on Linux) has less consistent performance and causes
  // strange crashes, see bug 1166778 and bug 1166808.  thread_suspend
  // is also just a lot simpler to use.

  if (KERN_SUCCESS != thread_suspend(samplee_thread)) {
    return;
  }

  //----------------------------------------------------------------//
  // Sample the target thread.

  // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  //
  // The profiler's "critical section" begins here.  We must be very careful
  // what we do here, or risk deadlock.  See the corresponding comment in
  // platform-linux-android.cpp for details.

#if defined(__x86_64__)
  thread_state_flavor_t flavor = x86_THREAD_STATE64;
  x86_thread_state64_t state;
  mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT;
#  if __DARWIN_UNIX03
#    define REGISTER_FIELD(name) __r##name
#  else
#    define REGISTER_FIELD(name) r##name
#  endif  // __DARWIN_UNIX03
#elif defined(__aarch64__)
  thread_state_flavor_t flavor = ARM_THREAD_STATE64;
  arm_thread_state64_t state;
  mach_msg_type_number_t count = ARM_THREAD_STATE64_COUNT;
#  if __DARWIN_UNIX03
#    define REGISTER_FIELD(name) __##name
#  else
#    define REGISTER_FIELD(name) name
#  endif  // __DARWIN_UNIX03
#else
#  error "unknown architecture"
#endif

  if (thread_get_state(samplee_thread, flavor,
                       reinterpret_cast(&state),
                       &count) == KERN_SUCCESS) {
    Registers regs;
#if defined(__x86_64__)
    regs.mPC = reinterpret_cast
(state.REGISTER_FIELD(ip)); regs.mSP = reinterpret_cast
(state.REGISTER_FIELD(sp)); regs.mFP = reinterpret_cast
(state.REGISTER_FIELD(bp)); #elif defined(__aarch64__) regs.mPC = reinterpret_cast
(state.REGISTER_FIELD(pc)); regs.mSP = reinterpret_cast
(state.REGISTER_FIELD(sp)); regs.mFP = reinterpret_cast
(state.REGISTER_FIELD(fp)); #else # error "unknown architecture" #endif regs.mLR = 0; aProcessRegs(regs, aNow); } #undef REGISTER_FIELD //----------------------------------------------------------------// // Resume the target thread. thread_resume(samplee_thread); // The profiler's critical section ends here. // // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING }

Minimal test - lines (37, 37)

path: .spaces[0].metrics.cognitive.average
old: null
new: 0.0

path: .spaces[0].metrics.halstead.vocabulary
old: 24.0
new: 7.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 90.56842503028857
new: 13.60964047443681

path: .spaces[0].metrics.halstead.difficulty
old: 3.1666666666666665
new: 2.5

path: .spaces[0].metrics.halstead.level
old: 0.31578947368421056
new: 0.4

path: .spaces[0].metrics.halstead.bugs
old: 0.03528133527337519
new: 0.0048876146417121315

path: .spaces[0].metrics.halstead.n1
old: 6.0
new: 5.0

path: .spaces[0].metrics.halstead.time
old: 60.49603299562635
new: 3.1192832467306713

path: .spaces[0].metrics.halstead.N1
old: 56.0
new: 6.0

path: .spaces[0].metrics.halstead.length
old: 75.0
new: 8.0

path: .spaces[0].metrics.halstead.effort
old: 1088.9285939212743
new: 56.14709844115208

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.2075790004038474
new: 1.7012050593046013

path: .spaces[0].metrics.halstead.volume
old: 343.8721875540867
new: 22.458839376460833

path: .spaces[0].metrics.halstead.N2
old: 19.0
new: 2.0

path: .spaces[0].metrics.halstead.n2
old: 18.0
new: 2.0

path: .spaces[0].metrics.mi.mi_sei
old: 100.24421022124548
new: 147.42610035996177

path: .spaces[0].metrics.mi.mi_visual_studio
old: 55.83898157250763
new: 90.4030653691422

path: .spaces[0].metrics.mi.mi_original
old: 95.48465848898805
new: 154.58924178123317

path: .spaces[0].metrics.nexits.average
old: null
new: 1.0

path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 1.0

path: .spaces[0].metrics.nom.total
old: 0.0
new: 1.0

path: .spaces[0].metrics.nom.functions
old: 0.0
new: 1.0

path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 1.0

path: .spaces[0].metrics.loc.cloc
old: 5.0
new: 0.0

path: .spaces[0].metrics.loc.sloc
old: 16.0
new: 1.0

path: .spaces[0].metrics.loc.ploc
old: 16.0
new: 1.0

path: .spaces[0].metrics.nargs.average
old: null
new: 0.0

Code

int profiler_current_process_id() { return getpid(); }

Minimal test - lines (84, 84)

path: .spaces[4].metrics.cyclomatic.average
old: 3.0
new: 1.0

path: .spaces[4].metrics.cyclomatic.sum
old: 3.0
new: 1.0

path: .spaces[4].metrics.mi.mi_sei
old: 103.78018482488712
new: 150.2034495661308

path: .spaces[4].metrics.mi.mi_original
old: 107.08294588933856
new: 156.51435355291963

path: .spaces[4].metrics.mi.mi_visual_studio
old: 62.62160578323892
new: 91.5288617268536

path: .spaces[4].metrics.nargs.average
old: 2.0
new: 1.0

path: .spaces[4].metrics.nargs.sum
old: 2.0
new: 1.0

path: .spaces[4].metrics.loc.lloc
old: 4.0
new: 0.0

path: .spaces[4].metrics.loc.ploc
old: 8.0
new: 1.0

path: .spaces[4].metrics.loc.sloc
old: 9.0
new: 1.0

path: .spaces[4].metrics.loc.cloc
old: 1.0
new: 0.0

path: .spaces[4].metrics.halstead.bugs
old: 0.08439683287262745
new: 0.0027165012951989257

path: .spaces[4].metrics.halstead.effort
old: 4028.7573057841696
new: 23.264662506490403

path: .spaces[4].metrics.halstead.difficulty
old: 19.833333333333332
new: 1.5

path: .spaces[4].metrics.halstead.estimated_program_length
old: 68.81274391313339
new: 9.509775004326936

path: .spaces[4].metrics.halstead.N1
old: 30.0
new: 3.0

path: .spaces[4].metrics.halstead.n1
old: 14.0
new: 3.0

path: .spaces[4].metrics.halstead.purity_ratio
old: 1.464100934321987
new: 1.584962500721156

path: .spaces[4].metrics.halstead.N2
old: 17.0
new: 3.0

path: .spaces[4].metrics.halstead.n2
old: 6.0
new: 3.0

path: .spaces[4].metrics.halstead.time
old: 223.81985032134276
new: 1.292481250360578

path: .spaces[4].metrics.halstead.volume
old: 203.13062045970605
new: 15.509775004326936

path: .spaces[4].metrics.halstead.vocabulary
old: 20.0
new: 6.0

path: .spaces[4].metrics.halstead.level
old: 0.05042016806722689
new: 0.6666666666666666

path: .spaces[4].metrics.halstead.length
old: 47.0
new: 6.0

path: .spaces[4].metrics.cognitive.average
old: 3.0
new: 0.0

path: .spaces[4].metrics.cognitive.sum
old: 3.0
new: 0.0

path: .spaces[4].metrics.nexits.average
old: 2.0
new: 0.0

path: .spaces[4].metrics.nexits.sum
old: 2.0
new: 0.0

Code

Sampler::Sampler(PSLockRef aLock) {}

Minimal test - lines (49, 52)

path: .spaces[2].metrics.loc.lloc
old: 0.0
new: 1.0

path: .spaces[2].metrics.mi.mi_original
old: 132.56043812602817
new: 126.19700005047748

path: .spaces[2].metrics.mi.mi_sei
old: 115.6452545698808
new: 106.4647540152798

path: .spaces[2].metrics.mi.mi_visual_studio
old: 77.52072405030886
new: 73.79941523419735

path: .spaces[2].metrics.nexits.sum
old: 0.0
new: 1.0

path: .spaces[2].metrics.nexits.average
old: null
new: 1.0

path: .spaces[2].metrics.nargs.average
old: null
new: 0.0

path: .spaces[2].metrics.halstead.n2
old: 2.0
new: 6.0

path: .spaces[2].metrics.halstead.vocabulary
old: 6.0
new: 13.0

path: .spaces[2].metrics.halstead.volume
old: 20.67970000576925
new: 70.30835464468075

path: .spaces[2].metrics.halstead.time
old: 2.2977444450854723
new: 15.949580451802577

path: .spaces[2].metrics.halstead.effort
old: 41.3594000115385
new: 287.09244813244635

path: .spaces[2].metrics.halstead.N1
old: 6.0
new: 12.0

path: .spaces[2].metrics.halstead.N2
old: 2.0
new: 7.0

path: .spaces[2].metrics.halstead.purity_ratio
old: 1.25
new: 1.850592603091061

path: .spaces[2].metrics.halstead.difficulty
old: 2.0
new: 4.083333333333333

path: .spaces[2].metrics.halstead.level
old: 0.5
new: 0.2448979591836735

path: .spaces[2].metrics.halstead.estimated_program_length
old: 10.0
new: 35.161259458730164

path: .spaces[2].metrics.halstead.bugs
old: 0.003986528732566614
new: 0.014506409214276324

path: .spaces[2].metrics.halstead.length
old: 8.0
new: 19.0

path: .spaces[2].metrics.halstead.n1
old: 4.0
new: 7.0

path: .spaces[2].metrics.nom.total
old: 0.0
new: 1.0

path: .spaces[2].metrics.nom.functions
old: 0.0
new: 1.0

path: .spaces[2].metrics.cognitive.average
old: null
new: 0.0

Code

void* GetStackTop(void* aGuess) {
  pthread_t thread = pthread_self();
  return pthread_get_stackaddr_np(thread);
}

Minimal test - lines (88, 92)

path: .spaces[6].metrics.nargs.average
old: 1.0
new: 2.0

path: .spaces[6].metrics.nargs.sum
old: 1.0
new: 2.0

path: .spaces[6].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[6].metrics.nexits.average
old: 1.0
new: 0.0

path: .spaces[6].metrics.mi.mi_original
old: 129.14768086864618
new: 122.58091524713564

path: .spaces[6].metrics.mi.mi_sei
old: 110.72168659889796
new: 133.1833369349149

path: .spaces[6].metrics.mi.mi_visual_studio
old: 75.52495957230771
new: 71.68474575855885

path: .spaces[6].metrics.loc.cloc
old: 0.0
new: 1.0

path: .spaces[6].metrics.loc.sloc
old: 4.0
new: 5.0

path: .spaces[6].metrics.halstead.difficulty
old: 3.0
new: 3.9375

path: .spaces[6].metrics.halstead.length
old: 12.0
new: 18.0

path: .spaces[6].metrics.halstead.bugs
old: 0.008091093705353408
new: 0.0141610338138407

path: .spaces[6].metrics.halstead.estimated_program_length
old: 23.509775004326936
new: 43.65148445440323

path: .spaces[6].metrics.halstead.purity_ratio
old: 1.9591479170272448
new: 2.4250824696890683

path: .spaces[6].metrics.halstead.vocabulary
old: 10.0
new: 15.0

path: .spaces[6].metrics.halstead.n2
old: 4.0
new: 8.0

path: .spaces[6].metrics.halstead.volume
old: 39.86313713864835
new: 70.32403072095333

path: .spaces[6].metrics.halstead.level
old: 0.3333333333333333
new: 0.25396825396825395

path: .spaces[6].metrics.halstead.n1
old: 6.0
new: 7.0

path: .spaces[6].metrics.halstead.N1
old: 8.0
new: 9.0

path: .spaces[6].metrics.halstead.time
old: 6.643856189774725
new: 15.38338172020854

path: .spaces[6].metrics.halstead.N2
old: 4.0
new: 9.0

path: .spaces[6].metrics.halstead.effort
old: 119.58941141594504
new: 276.90087096375373

Code

static void StreamMetaPlatformSampleUnits(PSLockRef aLock,
                                          SpliceableJSONWriter& aWriter) {
  // Microseconds.
  aWriter.StringProperty("threadCPUDelta", "\u00B5s");
}