Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  MozGTestBench.cpp   Sprache: C

 

/* 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>
#include <string>
#include <vector>

#define MOZ_GTEST_BENCH_FRAMEWORK "platform_microbench"
#define MOZ_GTEST_NUM_ITERATIONS 5

namespace mozilla {
void GTestBench(const char* aSuite, const char* aName,
                const std::function<void()>& aTest) {
#if defined(DEBUG) || defined(MOZ_ASAN)
  // 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
  bool shouldAlert = bool(getenv("PERFHERDER_ALERTING_ENABLED"));
  std::vector<int> durations;

  int iterations;
  if (!getenv("MOZ_GTEST_NUM_ITERATIONS") ||
      (iterations = atoi(getenv("MOZ_GTEST_NUM_ITERATIONS"))) == 0)
    iterations = MOZ_GTEST_NUM_ITERATIONS;

  for (int i = 0; i < iterations; i++) {
    mozilla::TimeStamp start = TimeStamp::Now();

    aTest();

    durations.push_back((TimeStamp::Now() - start).ToMicroseconds());
  }

  std::string replicatesStr = "[" + std::to_string(durations[0]);
  for (int i = 1; i < iterations; i++) {
    replicatesStr += "," + std::to_string(durations[i]);
  }
  replicatesStr += "]";

  // median is at index floor(i/2) if number of replicates is odd,
  // (i/2-1) if even
  std::sort(durations.begin(), durations.end());
  int medianIndex = (iterations / 2) + ((iterations % 2 == 0) ? (-1) : 0);

  // 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, \"replicates\": %s, "
      "\"lowerIsBetter\": true, \"shouldAlert\": %s}]"
      "}]}\n",
      MOZ_GTEST_BENCH_FRAMEWORK, aSuite, aName, durations[medianIndex],
      replicatesStr.c_str(), shouldAlert ? "true" : "false");
#endif
}

}  // namespace mozilla

Messung
CHZG
87949692

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1102655
#Domains=556575