• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #856

28 Dec 2022 02:00AM UTC coverage: 86.602% (+0.05%) from 86.55%
#856

push

StellarBot
Merge #6119

6119: Update CMakeLists.txt r=hkaiser a=khuck

updating the default APEX version


Co-authored-by: Kevin Huck <khuck@cs.uoregon.edu>

174566 of 201573 relevant lines covered (86.6%)

1876093.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.11
/libs/core/testing/src/performance.cpp
1
//  Copyright (c) 2021 ETH Zurich
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/testing/performance.hpp>
8

9
#include <chrono>
10
#include <cstddef>
11
#include <iostream>
12
#include <map>
13
#include <string>
14
#include <tuple>
15
#include <type_traits>
16
#include <vector>
17

18
namespace hpx::util {
19

20
    namespace detail {
21

22
        // Json output for performance reports
23
        class json_perf_times
4✔
24
        {
25
            using key_t = std::tuple<std::string, std::string>;
26
            using value_t = std::vector<double>;
27
            using map_t = std::map<key_t, value_t>;
28

29
            map_t m_map;
30

31
            HPX_CORE_EXPORT friend std::ostream& operator<<(
32
                std::ostream& strm, json_perf_times const& obj);
33

34
        public:
35
            HPX_CORE_EXPORT void add(std::string const& name,
36
                std::string const& executor, double time);
37
        };
38

39
        json_perf_times& times()
422✔
40
        {
41
            static json_perf_times res;
422✔
42
            return res;
422✔
43
        }
44

45
        void add_time(std::string const& test_name, std::string const& executor,
420✔
46
            double time)
47
        {
48
            times().add(test_name, executor, time);
420✔
49
        }
420✔
50

51
        std::ostream& operator<<(std::ostream& strm, json_perf_times const& obj)
2✔
52
        {
53
            strm << "{\n";
2✔
54
            strm << "  \"outputs\" : [";
2✔
55
            int outputs = 0;
2✔
56
            for (auto&& item : obj.m_map)
17✔
57
            {
58
                if (outputs)
15✔
59
                    strm << ",";
13✔
60
                strm << "\n    {\n";
15✔
61
                strm << "      \"name\" : \"" << std::get<0>(item.first)
15✔
62
                     << "\",\n";
15✔
63
                strm << "      \"executor\" : \"" << std::get<1>(item.first)
15✔
64
                     << "\",\n";
15✔
65
                strm << "      \"series\" : [";
15✔
66
                int series = 0;
15✔
67
                for (auto val : item.second)
435✔
68
                {
69
                    if (series)
420✔
70
                        strm << ", ";
405✔
71
                    strm << val;
420✔
72
                    ++series;
420✔
73
                }
74
                strm << "]\n";
15✔
75
                strm << "    }";
15✔
76
                ++outputs;
15✔
77
            }
78
            if (outputs)
2✔
79
                strm << "\n  ";
2✔
80
            strm << "]\n";
2✔
81
            strm << "}\n";
2✔
82
            return strm;
2✔
83
        }
84

85
        void json_perf_times::add(
420✔
86
            std::string const& name, std::string const& executor, double time)
87
        {
88
            m_map[key_t(name, executor)].push_back(time);
420✔
89
        }
420✔
90
    }    // namespace detail
91

92
    void perftests_report(std::string const& name, std::string const& exec,
15✔
93
        std::size_t const steps, hpx::function<void(void)>&& test)
94
    {
95
        if (steps == 0)
15✔
96
            return;
×
97

98
        // First iteration to cache the data
99
        test();
15✔
100
        using timer = std::chrono::high_resolution_clock;
101
        timer::time_point start;
15✔
102
        for (size_t i = 0; i != steps; ++i)
435✔
103
        {
104
            // For now we don't flush the cache
105
            //flush_cache();
106
            start = timer::now();
420✔
107
            test();
420✔
108
            // default is in seconds
109
            auto time =
110
                std::chrono::duration_cast<std::chrono::duration<double>>(
420✔
111
                    timer::now() - start);
420✔
112
            detail::add_time(name, exec, time.count());
420✔
113
        }
420✔
114
    }
15✔
115

116
    void perftests_print_times()
2✔
117
    {
118
        std::cout << detail::times();
2✔
119
    }
2✔
120
}    // namespace hpx::util
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc