Edit

kc3-lang/angle/src/tests/test_utils/runner/HistogramWriter.h

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2020-10-31 12:33:28
    Hash : 3e5b6f81
    Message : Enable writing histogram-set-json-format. This uses the protobuf histogram functionality to build up a histogram set. The test suites then output the histograms to JSON. This is only implemented for angle_perftests. Bug: angleproject:5161 Change-Id: Ia5a7868e8d8dcf4f13d83115ae622828c63ef0d9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2482295 Reviewed-by: Brian Sheedy <bsheedy@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>

  • src/tests/test_utils/runner/HistogramWriter.h
  • //
    // Copyright 2020 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // HistogramWriter:
    //   Helper class for writing histogram-json-set-format files to JSON.
    
    #ifndef ANGLE_TESTS_TEST_UTILS_HISTOGRAM_WRITER_H_
    #define ANGLE_TESTS_TEST_UTILS_HISTOGRAM_WRITER_H_
    
    #include <map>
    #include <memory>
    #include <string>
    
    // Include forward delcarations for rapidjson types.
    #include <rapidjson/fwd.h>
    
    namespace catapult
    {
    class HistogramBuilder;
    }  // namespace catapult
    
    namespace angle
    {
    class HistogramWriter
    {
      public:
        HistogramWriter();
        ~HistogramWriter();
    
        void addSample(const std::string &measurement,
                       const std::string &story,
                       double value,
                       const std::string &units);
    
        void getAsJSON(rapidjson::Document *doc) const;
    
      private:
    #if defined(ANGLE_HAS_HISTOGRAMS)
        std::map<std::string, std::unique_ptr<catapult::HistogramBuilder>> mHistograms;
    #endif  // defined(ANGLE_HAS_HISTOGRAMS)
    };
    
    // Define a stub implementation when histograms are compiled out.
    #if !defined(ANGLE_HAS_HISTOGRAMS)
    inline HistogramWriter::HistogramWriter()  = default;
    inline HistogramWriter::~HistogramWriter() = default;
    inline void HistogramWriter::addSample(const std::string &measurement,
                                           const std::string &story,
                                           double value,
                                           const std::string &units)
    {}
    inline void HistogramWriter::getAsJSON(rapidjson::Document *doc) const {}
    #endif  // !defined(ANGLE_HAS_HISTOGRAMS)
    
    }  // namespace angle
    
    #endif  // ANGLE_TESTS_TEST_UTILS_HISTOGRAM_WRITER_H_