Bug 1323238 - Backout platform microbenchmarks draft
authorWilliam Lachance <wlachance@mozilla.com>
Wed, 05 Apr 2017 14:31:15 -0400
changeset 556359 9e153ad25d37c020c5cecd3bbc2d269eec2b2bb9
parent 556295 720b9177c6856c1c4339d0fac1bf5149c0d53950
child 622866 992c5597e57d8141ce11b3154731446cbce7fddc
push id52523
push userwlachance@mozilla.com
push dateWed, 05 Apr 2017 18:42:07 +0000
bugs1323238
milestone55.0a1
Bug 1323238 - Backout platform microbenchmarks MozReview-Commit-ID: Likj41eXIcc
gfx/tests/gtest/TestCompositor.cpp
gfx/tests/gtest/TestRegion.cpp
testing/gtest/moz.build
testing/gtest/mozilla/MozGTestBench.cpp
testing/gtest/mozilla/MozGTestBench.h
testing/gtest/mozilla/moz.build
--- a/gfx/tests/gtest/TestCompositor.cpp
+++ b/gfx/tests/gtest/TestCompositor.cpp
@@ -1,17 +1,16 @@
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 #include "gfxPrefs.h"
 #include "gfxUtils.h"
 #include "gtest/gtest.h"
-#include "gtest/MozGTestBench.h"
 #include "TestLayers.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/LayerManagerComposite.h"
@@ -162,56 +161,49 @@ static bool CompositeAndCompare(RefPtr<L
   return true;
 }
 
 TEST(Gfx, CompositorConstruct)
 {
   auto layerManagers = GetLayerManagers(GetPlatformBackends());
 }
 
-static void CompositorSimpleTree() {
-  const int benchmarkRepeatCount = 30;
-
-  RefPtr<DrawTarget> refDT = CreateDT();
-  refDT->FillRect(Rect(0, 0, gCompWidth, gCompHeight), ColorPattern(Color(1.f, 0.f, 1.f, 1.f)));
-  refDT->FillRect(Rect(0, 0, 100, 100), ColorPattern(Color(1.f, 0.f, 0.f, 1.f)));
-  refDT->FillRect(Rect(0, 50, 100, 100), ColorPattern(Color(0.f, 0.f, 1.f, 1.f)));
-
+TEST(Gfx, CompositorSimpleTree)
+{
   auto layerManagers = GetLayerManagers(GetPlatformBackends());
   for (size_t i = 0; i < layerManagers.size(); i++) {
-    // Benchmark n composites
-    for (size_t n = 0; n < benchmarkRepeatCount; n++) {
-      RefPtr<LayerManagerComposite> layerManager = layerManagers[i].mLayerManager;
-      RefPtr<LayerManager> lmBase = layerManager.get();
-      nsTArray<RefPtr<Layer>> layers;
-      nsIntRegion layerVisibleRegion[] = {
-        nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)),
-        nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)),
-        nsIntRegion(IntRect(0, 0, 100, 100)),
-        nsIntRegion(IntRect(0, 50, 100, 100)),
-      };
-      RefPtr<Layer> root = CreateLayerTree("c(ooo)", layerVisibleRegion, nullptr, lmBase, layers);
+    RefPtr<LayerManagerComposite> layerManager = layerManagers[i].mLayerManager;
+    RefPtr<LayerManager> lmBase = layerManager.get();
+    nsTArray<RefPtr<Layer>> layers;
+    nsIntRegion layerVisibleRegion[] = {
+      nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)),
+      nsIntRegion(IntRect(0, 0, gCompWidth, gCompHeight)),
+      nsIntRegion(IntRect(0, 0, 100, 100)),
+      nsIntRegion(IntRect(0, 50, 100, 100)),
+    };
+    RefPtr<Layer> root = CreateLayerTree("c(ooo)", layerVisibleRegion, nullptr, lmBase, layers);
 
-      { // background
-        ColorLayer* colorLayer = layers[1]->AsColorLayer();
-        colorLayer->SetColor(Color(1.f, 0.f, 1.f, 1.f));
-        colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
-      }
+    { // background
+      ColorLayer* colorLayer = layers[1]->AsColorLayer();
+      colorLayer->SetColor(Color(1.f, 0.f, 1.f, 1.f));
+      colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
+    }
 
-      {
-        ColorLayer* colorLayer = layers[2]->AsColorLayer();
-        colorLayer->SetColor(Color(1.f, 0.f, 0.f, 1.f));
-        colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
-      }
+    {
+      ColorLayer* colorLayer = layers[2]->AsColorLayer();
+      colorLayer->SetColor(Color(1.f, 0.f, 0.f, 1.f));
+      colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
+    }
 
-      {
-        ColorLayer* colorLayer = layers[3]->AsColorLayer();
-        colorLayer->SetColor(Color(0.f, 0.f, 1.f, 1.f));
-        colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
-      }
+    {
+      ColorLayer* colorLayer = layers[3]->AsColorLayer();
+      colorLayer->SetColor(Color(0.f, 0.f, 1.f, 1.f));
+      colorLayer->SetBounds(colorLayer->GetVisibleRegion().ToUnknownRegion().GetBounds());
+    }
 
-      EXPECT_TRUE(CompositeAndCompare(layerManager, refDT));
-    }
+    RefPtr<DrawTarget> refDT = CreateDT();
+    refDT->FillRect(Rect(0, 0, gCompWidth, gCompHeight), ColorPattern(Color(1.f, 0.f, 1.f, 1.f)));
+    refDT->FillRect(Rect(0, 0, 100, 100), ColorPattern(Color(1.f, 0.f, 0.f, 1.f)));
+    refDT->FillRect(Rect(0, 50, 100, 100), ColorPattern(Color(0.f, 0.f, 1.f, 1.f)));
+    EXPECT_TRUE(CompositeAndCompare(layerManager, refDT));
   }
-};
+}
 
-MOZ_GTEST_BENCH(GfxBench, CompositorSimpleTree, &CompositorSimpleTree);
-
--- a/gfx/tests/gtest/TestRegion.cpp
+++ b/gfx/tests/gtest/TestRegion.cpp
@@ -2,18 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 
 #include "PingPongRegion.h"
 #include "gtest/gtest.h"
-#include "gtest/MozGTestBench.h"
-#include "nsRect.h"
 #include "nsRegion.h"
 #include "RegionBuilder.h"
 #include "mozilla/gfx/TiledRegion.h"
 #include "mozilla/UniquePtr.h"
 
 using namespace std;
 using namespace mozilla::gfx;
 
@@ -765,73 +763,8 @@ TEST(Gfx, TiledRegionNegativeRect) {
   // Rects with negative widths/heights are treated as empty and ignored
   tiledRegion.Add(nsIntRect(0, 0, -500, -500));
   EXPECT_FALSE(tiledRegion.Contains(nsIntRect(-1, -1, 1, 1)));
   EXPECT_FALSE(tiledRegion.Contains(nsIntRect(0, 0, 1, 1)));
   // Empty rects are always contained
   EXPECT_TRUE(tiledRegion.Contains(nsIntRect(0, 0, -1, -1)));
   EXPECT_TRUE(tiledRegion.Contains(nsIntRect(100, 100, -1, -1)));
 }
-
-MOZ_GTEST_BENCH(GfxBench, RegionOr, []{
-  const int size = 5000;
-
-  nsRegion r;
-  for (int i = 0; i < size; i++) {
-    r = r.Or(r, nsRect(i, i, i + 10, i + 10));
-  }
-
-  nsIntRegion rInt;
-  for (int i = 0; i < size; i++) {
-    rInt = rInt.Or(rInt, nsIntRect(i, i, i + 10, i + 10));
-  }
-});
-
-MOZ_GTEST_BENCH(GfxBench, RegionAnd, []{
-  const int size = 5000;
-  nsRegion r(nsRect(0, 0, size, size));
-  for (int i = 0; i < size; i++) {
-    nsRegion rMissingPixel(nsRect(0, 0, size, size));
-    rMissingPixel = rMissingPixel.Sub(rMissingPixel, nsRect(i, i, 1, 1));
-    r = r.And(r, rMissingPixel);
-  }
-});
-
-void BenchRegionBuilderOr() {
-  const int size = 5000;
-
-  RegionBuilder<nsRegion> r;
-  for (int i = 0; i < size; i++) {
-    r.OrWith(nsRect(i, i, i + 10, i + 10));
-  }
-  r.ToRegion();
-
-  RegionBuilder<nsIntRegion> rInt;
-  for (int i = 0; i < size; i++) {
-    rInt.OrWith(nsIntRect(i, i, i + 10, i + 10));
-  }
-  rInt.ToRegion();
-}
-
-MOZ_GTEST_BENCH(GfxBench, RegionBuilderOr, []{
-  BenchRegionBuilderOr();
-});
-
-void BenchPingPongRegionOr() {
-  const int size = 5000;
-
-  PingPongRegion<nsRegion> r;
-  for (int i = 0; i < size; i++) {
-    r.OrWith(nsRect(i, i, i + 10, i + 10));
-  }
-  r.Region();
-
-  PingPongRegion<nsIntRegion> rInt;
-  for (int i = 0; i < size; i++) {
-    rInt.OrWith(nsIntRect(i, i, i + 10, i + 10));
-  }
-  rInt.Region();
-}
-
-MOZ_GTEST_BENCH(GfxBench, PingPongRegionOr, []{
-  BenchPingPongRegionOr();
-});
-
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -15,17 +15,16 @@ if CONFIG['ENABLE_TESTS']:
         'gtest/include/gtest/gtest-param-test.h',
         'gtest/include/gtest/gtest-printers.h',
         'gtest/include/gtest/gtest-spi.h',
         'gtest/include/gtest/gtest-test-part.h',
         'gtest/include/gtest/gtest-typed-test.h',
         'gtest/include/gtest/gtest.h',
         'gtest/include/gtest/gtest_pred_impl.h',
         'gtest/include/gtest/gtest_prod.h',
-        'mozilla/MozGTestBench.h',
     ]
     EXPORTS.gtest += gtest_exports
 
     # webrtc.org unit tests use this include path
     EXPORTS.testing.gtest.include.gtest += gtest_exports
 
     # GTest internal are exposed in gtest.h. See comment in gtest.h
     EXPORTS.gtest.internal += [
@@ -76,16 +75,17 @@ if CONFIG['ENABLE_TESTS']:
         'gmock/include/gmock/internal/custom/gmock-generated-actions.h',
         'gmock/include/gmock/internal/custom/gmock-matchers.h',
         'gmock/include/gmock/internal/custom/gmock-port.h',
     ]
 
     SOURCES += [
         'gmock/src/gmock-all.cc',
         'gtest/src/gtest-all.cc',
+        'mozilla/GTestRunner.cpp',
     ]
 
     Library('gtest')
 
     LOCAL_INCLUDES += [
         'gmock',
         'gmock/include',
         'gtest',
deleted file mode 100644
--- a/testing/gtest/mozilla/MozGTestBench.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "MozGTestBench.h"
-#include "mozilla/TimeStamp.h"
-#include <stdio.h>
-
-#define MOZ_GTEST_BENCH_FRAMEWORK "platform_microbench"
-
-using mozilla::TimeStamp;
-
-namespace mozilla {
-void GTestBench(const char* aSuite, const char* aName,
-                const std::function<void()>& aTest)
-{
-#ifdef DEBUG
-  // Run the test to make sure that it doesn't fail but don't log
-  // any measurements since it's not an optimized build.
-  aTest();
-#else
-  mozilla::TimeStamp start = TimeStamp::Now();
-
-  aTest();
-
-  int msDuration = (TimeStamp::Now() - start).ToMicroseconds();
-
-  // Print the result for each test. Let perfherder aggregate for us
-  printf("PERFHERDER_DATA: {\"framework\": {\"name\": \"%s\"}, "
-                           "\"suites\": [{\"name\": \"%s\", \"subtests\": "
-                               "[{\"name\": \"%s\", \"value\": %i, \"lowerIsBetter\": true}]"
-                           "}]}\n",
-                           MOZ_GTEST_BENCH_FRAMEWORK, aSuite, aName, msDuration);
-#endif
-}
-
-} // mozilla
-
deleted file mode 100644
--- a/testing/gtest/mozilla/MozGTestBench.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GTEST_MOZGTESTBENCH_H
-#define GTEST_MOZGTESTBENCH_H
-
-#include <functional>
-
-namespace mozilla {
-
-void GTestBench(const char* aSuite, const char* aName, const std::function<void()>& aTest);
-
-} //mozilla
-
-#define MOZ_GTEST_BENCH(suite, test, lambdaOrFunc) \
-TEST(suite, test) { \
-  mozilla::GTestBench(#suite, #test, lambdaOrFunc); \
-}
-
-#endif // GTEST_MOZGTESTBENCH_H
--- a/testing/gtest/mozilla/moz.build
+++ b/testing/gtest/mozilla/moz.build
@@ -1,17 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 if CONFIG['ENABLE_TESTS']:
     SOURCES += [
         'GTestRunner.cpp',
-        'MozGTestBench.cpp',
         'SanityTest.cpp',
     ]
 
     if CONFIG['OS_ARCH'] == 'WINNT':
         LOCAL_INCLUDES += [
             '/security/sandbox/chromium',
         ]