# Global Metrics

path: .metrics.cyclomatic.sum
old: 20.0
new: 12.0
path: .metrics.cyclomatic.average
old: 1.0
new: 2.4
path: .metrics.mi.mi_original
old: 31.66001785761931
new: 54.03992747449787
path: .metrics.mi.mi_sei
old: 6.7193704208199705
new: 34.47948733819692
path: .metrics.mi.mi_visual_studio
old: 18.51463032609316
new: 31.602296768712208
path: .metrics.nom.total
old: 15.0
new: 4.0
path: .metrics.nom.functions
old: 15.0
new: 4.0
path: .metrics.nexits.average
old: 0.26666666666666666
new: 0.25
path: .metrics.nexits.sum
old: 4.0
new: 1.0
path: .metrics.cognitive.average
old: 0.0
new: 2.5
path: .metrics.cognitive.sum
old: 0.0
new: 10.0
path: .metrics.nargs.average
old: 0.9333333333333332
new: 2.5
path: .metrics.nargs.sum
old: 14.0
new: 10.0
path: .metrics.halstead.estimated_program_length
old: 481.4866257866323
new: 374.4314753670902
path: .metrics.halstead.purity_ratio
old: 0.6102492088550473
new: 1.2078434689260973
path: .metrics.halstead.time
old: 13887.906545443686
new: 2913.6476894359935
path: .metrics.halstead.volume
old: 5057.009448612646
new: 1906.4216070464515
path: .metrics.halstead.difficulty
old: 49.43283582089552
new: 27.51
path: .metrics.halstead.level
old: 0.020229468599033816
new: 0.03635041802980734
path: .metrics.halstead.bugs
old: 1.3227718343174604
new: 0.46703752187617587
path: .metrics.halstead.N1
old: 421.0
new: 179.0
path: .metrics.halstead.n1
old: 18.0
new: 21.0
path: .metrics.halstead.vocabulary
old: 85.0
new: 71.0
path: .metrics.halstead.n2
old: 67.0
new: 50.0
path: .metrics.halstead.effort
old: 249982.31781798633
new: 52445.658409847885
path: .metrics.halstead.N2
old: 368.0
new: 131.0
path: .metrics.halstead.length
old: 789.0
new: 310.0
path: .metrics.loc.blank
old: 51.0
new: 2.0
path: .metrics.loc.lloc
old: 47.0
new: 19.0
path: .metrics.loc.cloc
old: 65.0
new: 19.0
path: .metrics.loc.sloc
old: 265.0
new: 102.0
path: .metrics.loc.ploc
old: 149.0
new: 81.0

# Spaces Data

## Minimal test - lines (42, 70)

path: .spaces[1].metrics.nargs.sum
old: 2.0
new: 3.0
path: .spaces[1].metrics.nargs.average
old: 2.0
new: 3.0
path: .spaces[1].metrics.mi.mi_sei
old: 87.0839711908958
new: 65.26810548367183
path: .spaces[1].metrics.mi.mi_original
old: 88.52294225787176
new: 83.7157540016238
path: .spaces[1].metrics.mi.mi_visual_studio
old: 51.76780248998349
new: 48.95658128749929
path: .spaces[1].metrics.loc.blank
old: 4.0
new: 0.0
path: .spaces[1].metrics.loc.lloc
old: 7.0
new: 8.0
path: .spaces[1].metrics.loc.sloc
old: 24.0
new: 29.0
path: .spaces[1].metrics.loc.cloc
old: 6.0
new: 2.0
path: .spaces[1].metrics.loc.ploc
old: 14.0
new: 27.0
path: .spaces[1].metrics.cyclomatic.average
old: 1.0
new: 4.0
path: .spaces[1].metrics.cyclomatic.sum
old: 1.0
new: 4.0
path: .spaces[1].metrics.halstead.difficulty
old: 9.75
new: 15.0
path: .spaces[1].metrics.halstead.length
old: 78.0
new: 90.0
path: .spaces[1].metrics.halstead.vocabulary
old: 27.0
new: 33.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.3280509620377232
new: 1.4851334328898822
path: .spaces[1].metrics.halstead.effort
old: 3616.0919453953175
new: 6809.932061133912
path: .spaces[1].metrics.halstead.N2
old: 39.0
new: 36.0
path: .spaces[1].metrics.halstead.N1
old: 39.0
new: 54.0
path: .spaces[1].metrics.halstead.time
old: 200.89399696640652
new: 378.329558951884
path: .spaces[1].metrics.halstead.estimated_program_length
old: 103.58797503894242
new: 133.6620089600894
path: .spaces[1].metrics.halstead.bugs
old: 0.07853050466071337
new: 0.11975875287263477
path: .spaces[1].metrics.halstead.level
old: 0.10256410256410256
new: 0.06666666666666667
path: .spaces[1].metrics.halstead.volume
old: 370.8812251687505
new: 453.9954707422608
path: .spaces[1].metrics.halstead.n1
old: 9.0
new: 15.0
path: .spaces[1].metrics.cognitive.sum
old: 0.0
new: 6.0
path: .spaces[1].metrics.cognitive.average
old: 0.0
new: 6.0

### Code

    ProfilerBacktrace::ProfilerBacktrace(
        const char* aName,
        mozilla::ProfileChunkedBuffer* aExternalProfileChunkedBuffer,
        ProfileBuffer* aExternalProfileBuffer)
        : mName(aName),
          mProfileChunkedBuffer(aExternalProfileChunkedBuffer),
          mProfileBuffer(aExternalProfileBuffer) {
      MOZ_COUNT_CTOR(ProfilerBacktrace);
      if (!mProfileChunkedBuffer) {
        if (mProfileBuffer) {
          // We don't have a ProfileChunkedBuffer but we have a ProfileBuffer, use
          // the latter's ProfileChunkedBuffer.
          mProfileChunkedBuffer = &mProfileBuffer->UnderlyingChunkedBuffer();
          MOZ_ASSERT(!mProfileChunkedBuffer->IsThreadSafe(),
                     "ProfilerBacktrace only takes a non-thread-safe "
                     "ProfileChunkedBuffer");
        }
      } else {
        if (mProfileBuffer) {
          MOZ_RELEASE_ASSERT(
              mProfileChunkedBuffer == &mProfileBuffer->UnderlyingChunkedBuffer(),
              "If we reference both ProfileChunkedBuffer and ProfileBuffer, they "
              "must already be connected");
        }
        MOZ_ASSERT(!mProfileChunkedBuffer->IsThreadSafe(),
                   "ProfilerBacktrace only takes a non-thread-safe "
                   "ProfileChunkedBuffer");
      }
    }

## Minimal test - lines (15, 40)

path: .spaces[0].metrics.nom.functions
old: 10.0
new: 1.0
path: .spaces[0].metrics.nom.total
old: 10.0
new: 1.0
path: .spaces[0].metrics.nargs.average
old: 0.4
new: 4.0
path: .spaces[0].metrics.nexits.sum
old: 4.0
new: 0.0
path: .spaces[0].metrics.nexits.average
old: 0.4
new: 0.0
path: .spaces[0].metrics.loc.cloc
old: 26.0
new: 1.0
path: .spaces[0].metrics.loc.lloc
old: 9.0
new: 5.0
path: .spaces[0].metrics.loc.blank
old: 13.0
new: 0.0
path: .spaces[0].metrics.loc.ploc
old: 42.0
new: 26.0
path: .spaces[0].metrics.loc.sloc
old: 81.0
new: 26.0
path: .spaces[0].metrics.cyclomatic.sum
old: 14.0
new: 3.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 3.0
path: .spaces[0].metrics.halstead.N1
old: 84.0
new: 55.0
path: .spaces[0].metrics.halstead.level
old: 0.06153846153846154
new: 0.07058823529411765
path: .spaces[0].metrics.halstead.vocabulary
old: 37.0
new: 41.0
path: .spaces[0].metrics.halstead.volume
old: 750.1612846505689
new: 508.967440438718
path: .spaces[0].metrics.halstead.difficulty
old: 16.25
new: 14.166666666666666
path: .spaces[0].metrics.halstead.length
old: 144.0
new: 95.0
path: .spaces[0].metrics.halstead.n1
old: 13.0
new: 17.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 158.14481635314195
new: 179.5259683185635
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.0982278913412635
new: 1.8897470349322476
path: .spaces[0].metrics.halstead.bugs
old: 0.17655665274402377
new: 0.12440863619777662
path: .spaces[0].metrics.halstead.time
old: 677.2289375317636
new: 400.5762262712132
path: .spaces[0].metrics.halstead.effort
old: 12190.120875571743
new: 7210.372072881838
path: .spaces[0].metrics.halstead.N2
old: 60.0
new: 40.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 2.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 2.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 36.353464853990715
new: 49.77803452671861
path: .spaces[0].metrics.mi.mi_sei
old: 53.87274130533392
new: 62.365900579712545
path: .spaces[0].metrics.mi.mi_original
old: 62.16442490032412
new: 85.12043904068884

### Code

    ProfilerBacktrace::ProfilerBacktrace(
        const char* aName,
        mozilla::UniquePtr
            aProfileChunkedBufferStorage,
        mozilla::UniquePtr
            aProfileBufferStorageOrNull /* = nullptr */)
        : mName(aName),
          mOptionalProfileChunkedBufferStorage(
              std::move(aProfileChunkedBufferStorage)),
          mProfileChunkedBuffer(mOptionalProfileChunkedBufferStorage.get()),
          mOptionalProfileBufferStorage(std::move(aProfileBufferStorageOrNull)),
          mProfileBuffer(mOptionalProfileBufferStorage.get()) {
      MOZ_COUNT_CTOR(ProfilerBacktrace);
      if (mProfileBuffer) {
        MOZ_RELEASE_ASSERT(mProfileChunkedBuffer,
                           "If we take ownership of a ProfileBuffer, we must also "
                           "receive ownership of a ProfileChunkedBuffer");
        MOZ_RELEASE_ASSERT(
            mProfileChunkedBuffer == &mProfileBuffer->UnderlyingChunkedBuffer(),
            "If we take ownership of a ProfileBuffer, we must also receive "
            "ownership of its ProfileChunkedBuffer");
      }
      MOZ_ASSERT(
          !mProfileChunkedBuffer || !mProfileChunkedBuffer->IsThreadSafe(),
          "ProfilerBacktrace only takes a non-thread-safe ProfileChunkedBuffer");
    }

## Minimal test - lines (72, 72)

path: .spaces[2].metrics.halstead.bugs
old: 0.1609764176447935
new: 0.006927759642225941
path: .spaces[2].metrics.halstead.effort
old: 10612.684896647528
new: 94.74822861944416
path: .spaces[2].metrics.halstead.volume
old: 750.3918613791182
new: 25.26619429851844
path: .spaces[2].metrics.halstead.n1
old: 12.0
new: 5.0
path: .spaces[2].metrics.halstead.difficulty
old: 14.142857142857142
new: 3.75
path: .spaces[2].metrics.halstead.level
old: 0.0707070707070707
new: 0.26666666666666666
path: .spaces[2].metrics.halstead.N1
old: 75.0
new: 6.0
path: .spaces[2].metrics.halstead.N2
old: 66.0
new: 3.0
path: .spaces[2].metrics.halstead.n2
old: 28.0
new: 2.0
path: .spaces[2].metrics.halstead.time
old: 589.5936053693072
new: 5.2637904788580085
path: .spaces[2].metrics.halstead.vocabulary
old: 40.0
new: 7.0
path: .spaces[2].metrics.halstead.length
old: 141.0
new: 9.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.2597552328104027
new: 1.5121822749374234
path: .spaces[2].metrics.halstead.estimated_program_length
old: 177.62548782626678
new: 13.60964047443681
path: .spaces[2].metrics.mi.mi_visual_studio
old: 46.05044709583131
new: 90.04489473439764
path: .spaces[2].metrics.mi.mi_sei
old: 69.94330373178894
new: 146.54249035246173
path: .spaces[2].metrics.mi.mi_original
old: 78.74626453387155
new: 153.97676999581998
path: .spaces[2].metrics.loc.lloc
old: 8.0
new: 1.0
path: .spaces[2].metrics.loc.sloc
old: 35.0
new: 1.0
path: .spaces[2].metrics.loc.cloc
old: 7.0
new: 0.0
path: .spaces[2].metrics.loc.blank
old: 6.0
new: 0.0
path: .spaces[2].metrics.loc.ploc
old: 22.0
new: 1.0
path: .spaces[2].metrics.nargs.average
old: 2.0
new: 0.0
path: .spaces[2].metrics.nargs.sum
old: 2.0
new: 0.0

### Code

    ProfilerBacktrace::~ProfilerBacktrace() { MOZ_COUNT_DTOR(ProfilerBacktrace); }

## Minimal test - lines (74, 102)

path: .spaces[3].metrics.nargs.average
old: 2.0
new: 3.0
path: .spaces[3].metrics.nargs.sum
old: 2.0
new: 3.0
path: .spaces[3].metrics.nexits.average
old: 0.0
new: 1.0
path: .spaces[3].metrics.nexits.sum
old: 0.0
new: 1.0
path: .spaces[3].metrics.halstead.length
old: 152.0
new: 111.0
path: .spaces[3].metrics.halstead.estimated_program_length
old: 171.40151256706753
new: 123.1643663617958
path: .spaces[3].metrics.halstead.time
old: 684.3617095237935
new: 518.5162777264634
path: .spaces[3].metrics.halstead.N2
old: 69.0
new: 47.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 1.1276415300464968
new: 1.1095888861423044
path: .spaces[3].metrics.halstead.effort
old: 12318.510771428282
new: 9333.29299907634
path: .spaces[3].metrics.halstead.vocabulary
old: 39.0
new: 31.0
path: .spaces[3].metrics.halstead.n1
old: 12.0
new: 13.0
path: .spaces[3].metrics.halstead.level
old: 0.06521739130434782
new: 0.058919803600654665
path: .spaces[3].metrics.halstead.difficulty
old: 15.333333333333334
new: 16.97222222222222
path: .spaces[3].metrics.halstead.bugs
old: 0.17779418404574124
new: 0.14776401342432008
path: .spaces[3].metrics.halstead.volume
old: 803.3811372670618
new: 549.9157904529432
path: .spaces[3].metrics.halstead.n2
old: 27.0
new: 18.0
path: .spaces[3].metrics.halstead.N1
old: 83.0
new: 64.0
path: .spaces[3].metrics.loc.lloc
old: 8.0
new: 5.0
path: .spaces[3].metrics.loc.sloc
old: 35.0
new: 29.0
path: .spaces[3].metrics.loc.blank
old: 7.0
new: 0.0
path: .spaces[3].metrics.loc.cloc
old: 6.0
new: 11.0
path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 2.0
path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 2.0
path: .spaces[3].metrics.cyclomatic.sum
old: 1.0
new: 3.0
path: .spaces[3].metrics.cyclomatic.average
old: 1.0
new: 3.0
path: .spaces[3].metrics.mi.mi_visual_studio
old: 45.84295283051471
new: 48.50820393648385
path: .spaces[3].metrics.mi.mi_original
old: 78.39144934018016
new: 82.94902873138739
path: .spaces[3].metrics.mi.mi_sei
old: 67.41289347982155
new: 85.06501419518486

### Code

    int ProfilerBacktrace::StreamJSON(SpliceableJSONWriter& aWriter,
                                      const mozilla::TimeStamp& aProcessStartTime,
                                      UniqueStacks& aUniqueStacks) {
      int processedThreadId = 0;

      // Unlike ProfiledThreadData::StreamJSON, we don't need to call
      // ProfileBuffer::AddJITInfoForRange because ProfileBuffer does not contain
      // any JitReturnAddr entries. For synchronous samples, JIT frames get expanded
      // at sample time.
      if (mProfileBuffer) {
        processedThreadId =
            StreamSamplesAndMarkers(mName.c_str(), 0, *mProfileBuffer, aWriter,
                                    ""_ns, ""_ns, aProcessStartTime,
                                    /* aRegisterTime */ mozilla::TimeStamp(),
                                    /* aUnregisterTime */ mozilla::TimeStamp(),
                                    /* aSinceTime */ 0, aUniqueStacks);
      } else if (mProfileChunkedBuffer) {
        ProfileBuffer profileBuffer(*mProfileChunkedBuffer);
        processedThreadId =
            StreamSamplesAndMarkers(mName.c_str(), 0, profileBuffer, aWriter, ""_ns,
                                    ""_ns, aProcessStartTime,
                                    /* aRegisterTime */ mozilla::TimeStamp(),
                                    /* aUnregisterTime */ mozilla::TimeStamp(),
                                    /* aSinceTime */ 0, aUniqueStacks);
      }
      // If there are no buffers, the backtrace is empty and nothing is streamed.

      return processedThreadId;
    }