Global Metrics

path: .metrics.loc.cloc
old: 5.0
new: 13.0

path: .metrics.loc.ploc
old: 49.0
new: 93.0

path: .metrics.loc.blank
old: 16.0
new: 8.0

path: .metrics.loc.lloc
old: 24.0
new: 33.0

path: .metrics.loc.sloc
old: 70.0
new: 114.0

path: .metrics.cognitive.average
old: 0.6666666666666666
new: 0.5

path: .metrics.cognitive.sum
old: 2.0
new: 5.0

path: .metrics.halstead.length
old: 211.0
new: 402.0

path: .metrics.halstead.estimated_program_length
old: 429.2538006245371
new: 401.68727970187007

path: .metrics.halstead.bugs
old: 0.2755204415780941
new: 0.6586210199495489

path: .metrics.halstead.time
old: 1320.201177315775
new: 4879.358832436058

path: .metrics.halstead.effort
old: 23763.621191683953
new: 87828.45898384905

path: .metrics.halstead.volume
old: 1330.0977378653688
new: 2503.985113579344

path: .metrics.halstead.n2
old: 56.0
new: 53.0

path: .metrics.halstead.level
old: 0.0559720139930035
new: 0.028509951586874666

path: .metrics.halstead.difficulty
old: 17.866071428571427
new: 35.075471698113205

path: .metrics.halstead.n1
old: 23.0
new: 22.0

path: .metrics.halstead.N1
old: 124.0
new: 233.0

path: .metrics.halstead.N2
old: 87.0
new: 169.0

path: .metrics.halstead.purity_ratio
old: 2.034378202012024
new: 0.999222088810622

path: .metrics.halstead.vocabulary
old: 79.0
new: 75.0

path: .metrics.cyclomatic.sum
old: 15.0
new: 8.0

path: .metrics.cyclomatic.average
old: 3.0
new: 1.6

path: .metrics.nargs.average
old: 1.0
new: 0.6

path: .metrics.nargs.sum
old: 3.0
new: 6.0

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

path: .metrics.nom.total
old: 3.0
new: 10.0

path: .metrics.mi.mi_sei
old: 34.40910032671627
new: 24.739622427469744

path: .metrics.mi.mi_original
old: 61.32073700951099
new: 51.74026344284921

path: .metrics.mi.mi_visual_studio
old: 35.86008012252105
new: 30.257464001666204

path: .metrics.nexits.sum
old: 11.0
new: 0.0

path: .metrics.nexits.average
old: 3.6666666666666665
new: 0.0

Spaces Data

Minimal test - lines (17, 84)

path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 2.0
new: 4.0

path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 4.0

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

path: .spaces[0].spaces[0].metrics.nom.closures
old: 0.0
new: 5.0

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

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

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

path: .spaces[0].spaces[0].metrics.loc.lloc
old: 3.0
new: 25.0

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

path: .spaces[0].spaces[0].metrics.loc.ploc
old: 6.0
new: 61.0

path: .spaces[0].spaces[0].metrics.loc.sloc
old: 6.0
new: 68.0

path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 91.72064659950138
new: 38.3892069178547

path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 115.90658741688642
new: 63.40727077926603

path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 67.78163006835464
new: 37.080275309512295

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

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

path: .spaces[0].spaces[0].metrics.cognitive.average
old: 1.0
new: 0.8333333333333334

path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 1.0
new: 5.0

path: .spaces[0].spaces[0].metrics.halstead.N1
old: 21.0
new: 163.0

path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 6.0
new: 35.588235294117645

path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.029336459638526713
new: 0.4903547556384591

path: .spaces[0].spaces[0].metrics.halstead.effort
old: 825.6451502855779
new: 56421.869158920235

path: .spaces[0].spaces[0].metrics.halstead.volume
old: 137.6075250475963
new: 1585.4078937217257

path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 57.05865002596162
new: 271.0812322125321

path: .spaces[0].spaces[0].metrics.halstead.N2
old: 12.0
new: 110.0

path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 18.0
new: 56.0

path: .spaces[0].spaces[0].metrics.halstead.time
old: 45.86917501586544
new: 3134.5482866066795

path: .spaces[0].spaces[0].metrics.halstead.length
old: 33.0
new: 273.0

path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.7290500007867158
new: 0.9929715465660516

path: .spaces[0].spaces[0].metrics.halstead.n2
old: 9.0
new: 34.0

path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.16666666666666666
new: 0.02809917355371901

path: .spaces[0].spaces[0].metrics.halstead.n1
old: 9.0
new: 22.0

Code

TEST(TaskQueue, EventOrder)
{
  RefPtr tq1 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
  RefPtr tq2 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
  RefPtr tq3 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);

  bool errored = false;
  int counter = 0;
  int sync = 0;
  Monitor monitor("TaskQueue::EventOrder::monitor");

  // We expect task1 happens before task3.
  for (int i = 0; i < 10000; ++i) {
    Unused << tq1->Dispatch(
        NS_NewRunnableFunction(
            "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
            [&]() {
              Unused << tq2->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  []() {  // task0
                  }));
              Unused << tq3->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  [&]() {  // task1
                    EXPECT_EQ(1, ++counter);
                    errored = counter != 1;
                    MonitorAutoLock mon(monitor);
                    ++sync;
                    mon.Notify();
                  }));
              Unused << tq2->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  [&]() {  // task2
                    Unused << tq3->Dispatch(NS_NewRunnableFunction(
                        "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                        [&]() {  // task3
                          EXPECT_EQ(0, --counter);
                          errored = counter != 0;
                          MonitorAutoLock mon(monitor);
                          ++sync;
                          mon.Notify();
                        }));
                  }));
            }),
        AbstractThread::TailDispatch);

    // Ensure task1 and task3 are done before next loop.
    MonitorAutoLock mon(monitor);
    while (sync != 2) {
      mon.Wait();
    }
    sync = 0;

    if (errored) {
      break;
    }
  }

  tq1->BeginShutdown();
  tq1->AwaitShutdownAndIdle();
  tq2->BeginShutdown();
  tq2->AwaitShutdownAndIdle();
  tq3->BeginShutdown();
  tq3->AwaitShutdownAndIdle();
}

Minimal test - lines (99, 112)

path: .spaces[0].spaces[2].metrics.halstead.bugs
old: 0.1532212258147022
new: 0.05732411827509793

path: .spaces[0].spaces[2].metrics.halstead.difficulty
old: 14.796296296296296
new: 8.088235294117647

path: .spaces[0].spaces[2].metrics.halstead.n2
old: 27.0
new: 17.0

path: .spaces[0].spaces[2].metrics.halstead.N1
old: 75.0
new: 33.0

path: .spaces[0].spaces[2].metrics.halstead.time
old: 547.5046042402535
new: 125.28972386735092

path: .spaces[0].spaces[2].metrics.halstead.level
old: 0.06758448060075094
new: 0.12363636363636364

path: .spaces[0].spaces[2].metrics.halstead.effort
old: 9855.082876324564
new: 2255.215029612317

path: .spaces[0].spaces[2].metrics.halstead.N2
old: 47.0
new: 25.0

path: .spaces[0].spaces[2].metrics.halstead.purity_ratio
old: 1.6218756627841755
new: 1.8541485535563111

path: .spaces[0].spaces[2].metrics.halstead.estimated_program_length
old: 197.8688308596694
new: 107.54061610626604

path: .spaces[0].spaces[2].metrics.halstead.volume
old: 666.0506574737502
new: 278.826585479341

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

path: .spaces[0].spaces[2].metrics.halstead.vocabulary
old: 44.0
new: 28.0

path: .spaces[0].spaces[2].metrics.halstead.length
old: 122.0
new: 58.0

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

path: .spaces[0].spaces[2].metrics.cyclomatic.sum
old: 9.0
new: 1.0

path: .spaces[0].spaces[2].metrics.cyclomatic.average
old: 9.0
new: 1.0

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

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

path: .spaces[0].spaces[2].metrics.mi.mi_sei
old: 37.739763864421846
new: 86.9656150638919

path: .spaces[0].spaces[2].metrics.mi.mi_original
old: 77.99585770563056
new: 98.7382030982385

path: .spaces[0].spaces[2].metrics.mi.mi_visual_studio
old: 45.6116126933512
new: 57.74163923873597

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

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

path: .spaces[0].spaces[2].metrics.loc.blank
old: 9.0
new: 1.0

path: .spaces[0].spaces[2].metrics.loc.sloc
old: 34.0
new: 14.0

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

path: .spaces[0].spaces[2].metrics.loc.lloc
old: 19.0
new: 4.0

path: .spaces[0].spaces[2].metrics.loc.ploc
old: 25.0
new: 12.0

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

path: .spaces[0].spaces[2].metrics.nexits.average
old: 9.0
new: 0.0

Code

TEST(AbstractThread, GetCurrentSerialEventTarget)
{
  RefPtr mainThread = AbstractThread::GetCurrent();
  EXPECT_EQ(mainThread, AbstractThread::MainThread());
  Unused << mainThread->Dispatch(NS_NewRunnableFunction(
      "TestAbstractThread::TestCurrentSerialEventTarget::TestBody",
      [mainThread]() {
        nsCOMPtr thread = GetCurrentSerialEventTarget();
        EXPECT_EQ(thread, mainThread);
      }));

  // Spin the event loop.
  NS_ProcessPendingEvents(nullptr);
}

Minimal test - lines (13, 114)

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

path: .spaces[0].metrics.nexits.average
old: 3.6666666666666665
new: 0.0

path: .spaces[0].metrics.loc.ploc
old: 42.0
new: 88.0

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

path: .spaces[0].metrics.loc.sloc
old: 56.0
new: 102.0

path: .spaces[0].metrics.loc.blank
old: 14.0
new: 7.0

path: .spaces[0].metrics.loc.lloc
old: 24.0
new: 33.0

path: .spaces[0].metrics.cyclomatic.average
old: 3.5
new: 1.75

path: .spaces[0].metrics.cyclomatic.sum
old: 14.0
new: 7.0

path: .spaces[0].metrics.halstead.n1
old: 23.0
new: 22.0

path: .spaces[0].metrics.halstead.volume
old: 1258.6647002942316
new: 2433.3253577271516

path: .spaces[0].metrics.halstead.level
old: 0.05326086956521739
new: 0.02660753880266075

path: .spaces[0].metrics.halstead.N2
old: 80.0
new: 164.0

path: .spaces[0].metrics.halstead.vocabulary
old: 72.0
new: 70.0

path: .spaces[0].metrics.halstead.N1
old: 124.0
new: 233.0

path: .spaces[0].metrics.halstead.difficulty
old: 18.77551020408163
new: 37.583333333333336

path: .spaces[0].metrics.halstead.bugs
old: 0.2745026944751651
new: 0.6766162083768327

path: .spaces[0].metrics.halstead.estimated_program_length
old: 379.16270735095645
new: 366.185695644636

path: .spaces[0].metrics.halstead.length
old: 204.0
new: 397.0

path: .spaces[0].metrics.halstead.time
old: 1312.8928846606498
new: 5080.693223772895

path: .spaces[0].metrics.halstead.effort
old: 23632.071923891697
new: 91452.47802791212

path: .spaces[0].metrics.halstead.n2
old: 49.0
new: 48.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.85864072230861
new: 0.9223821048983276

path: .spaces[0].metrics.nom.closures
old: 0.0
new: 7.0

path: .spaces[0].metrics.nom.total
old: 3.0
new: 10.0

path: .spaces[0].metrics.mi.mi_visual_studio
old: 38.2764373644301
new: 31.532729420203715

path: .spaces[0].metrics.mi.mi_original
old: 65.45270789317547
new: 53.92096730854835

path: .spaces[0].metrics.mi.mi_sei
old: 20.15292312988791
new: 22.54291988889512

path: .spaces[0].metrics.cognitive.sum
old: 2.0
new: 5.0

path: .spaces[0].metrics.cognitive.average
old: 0.6666666666666666
new: 0.5

path: .spaces[0].metrics.nargs.sum
old: 3.0
new: 6.0

path: .spaces[0].metrics.nargs.average
old: 1.0
new: 0.6

Code

namespace TestTaskQueue {

using namespace mozilla;

TEST(TaskQueue, EventOrder)
{
  RefPtr tq1 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
  RefPtr tq2 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);
  RefPtr tq3 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), true);

  bool errored = false;
  int counter = 0;
  int sync = 0;
  Monitor monitor("TaskQueue::EventOrder::monitor");

  // We expect task1 happens before task3.
  for (int i = 0; i < 10000; ++i) {
    Unused << tq1->Dispatch(
        NS_NewRunnableFunction(
            "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
            [&]() {
              Unused << tq2->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  []() {  // task0
                  }));
              Unused << tq3->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  [&]() {  // task1
                    EXPECT_EQ(1, ++counter);
                    errored = counter != 1;
                    MonitorAutoLock mon(monitor);
                    ++sync;
                    mon.Notify();
                  }));
              Unused << tq2->Dispatch(NS_NewRunnableFunction(
                  "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                  [&]() {  // task2
                    Unused << tq3->Dispatch(NS_NewRunnableFunction(
                        "TestTaskQueue::TaskQueue_EventOrder_Test::TestBody",
                        [&]() {  // task3
                          EXPECT_EQ(0, --counter);
                          errored = counter != 0;
                          MonitorAutoLock mon(monitor);
                          ++sync;
                          mon.Notify();
                        }));
                  }));
            }),
        AbstractThread::TailDispatch);

    // Ensure task1 and task3 are done before next loop.
    MonitorAutoLock mon(monitor);
    while (sync != 2) {
      mon.Wait();
    }
    sync = 0;

    if (errored) {
      break;
    }
  }

  tq1->BeginShutdown();
  tq1->AwaitShutdownAndIdle();
  tq2->BeginShutdown();
  tq2->AwaitShutdownAndIdle();
  tq3->BeginShutdown();
  tq3->AwaitShutdownAndIdle();
}

TEST(TaskQueue, GetCurrentSerialEventTarget)
{
  RefPtr tq1 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), false);
  Unused << tq1->Dispatch(NS_NewRunnableFunction(
      "TestTaskQueue::TestCurrentSerialEventTarget::TestBody", [tq1]() {
        nsCOMPtr thread = GetCurrentSerialEventTarget();
        EXPECT_EQ(thread, tq1);
      }));
  tq1->BeginShutdown();
  tq1->AwaitShutdownAndIdle();
}

TEST(AbstractThread, GetCurrentSerialEventTarget)
{
  RefPtr mainThread = AbstractThread::GetCurrent();
  EXPECT_EQ(mainThread, AbstractThread::MainThread());
  Unused << mainThread->Dispatch(NS_NewRunnableFunction(
      "TestAbstractThread::TestCurrentSerialEventTarget::TestBody",
      [mainThread]() {
        nsCOMPtr thread = GetCurrentSerialEventTarget();
        EXPECT_EQ(thread, mainThread);
      }));

  // Spin the event loop.
  NS_ProcessPendingEvents(nullptr);
}

}  // namespace TestTaskQueue

Minimal test - lines (86, 97)

path: .spaces[0].spaces[1].metrics.mi.mi_original
old: 109.82251528363672
new: 100.78208307252726

path: .spaces[0].spaces[1].metrics.mi.mi_sei
old: 82.94318590445127
new: 69.79877932658633

path: .spaces[0].spaces[1].metrics.mi.mi_visual_studio
old: 64.22369314832558
new: 58.936890685688454

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

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

path: .spaces[0].spaces[1].metrics.cyclomatic.average
old: 2.0
new: 1.0

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

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

path: .spaces[0].spaces[1].metrics.loc.ploc
old: 8.0
new: 12.0

path: .spaces[0].spaces[1].metrics.loc.sloc
old: 8.0
new: 12.0

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

path: .spaces[0].spaces[1].metrics.halstead.length
old: 40.0
new: 62.0

path: .spaces[0].spaces[1].metrics.halstead.bugs
old: 0.034367168870738006
new: 0.06523877454479053

path: .spaces[0].spaces[1].metrics.halstead.difficulty
old: 5.785714285714286
new: 9.0

path: .spaces[0].spaces[1].metrics.halstead.effort
old: 1046.8814812589087
new: 2738.044952349553

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

path: .spaces[0].spaces[1].metrics.halstead.level
old: 0.1728395061728395
new: 0.1111111111111111

path: .spaces[0].spaces[1].metrics.halstead.volume
old: 180.94247824228052
new: 304.22721692772814

path: .spaces[0].spaces[1].metrics.halstead.N2
old: 18.0
new: 27.0

path: .spaces[0].spaces[1].metrics.halstead.N1
old: 22.0
new: 35.0

path: .spaces[0].spaces[1].metrics.halstead.purity_ratio
old: 2.045807348044682
new: 1.904487097332508

path: .spaces[0].spaces[1].metrics.halstead.estimated_program_length
old: 81.83229392178727
new: 118.07820003461548

path: .spaces[0].spaces[1].metrics.halstead.time
old: 58.1600822921616
new: 152.11360846386407

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

path: .spaces[0].spaces[1].metrics.halstead.vocabulary
old: 23.0
new: 30.0

Code

TEST(TaskQueue, GetCurrentSerialEventTarget)
{
  RefPtr tq1 =
      new TaskQueue(GetMediaThreadPool(MediaThreadType::SUPERVISOR), false);
  Unused << tq1->Dispatch(NS_NewRunnableFunction(
      "TestTaskQueue::TestCurrentSerialEventTarget::TestBody", [tq1]() {
        nsCOMPtr thread = GetCurrentSerialEventTarget();
        EXPECT_EQ(thread, tq1);
      }));
  tq1->BeginShutdown();
  tq1->AwaitShutdownAndIdle();
}