MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / MetricListSample

Function MetricListSample

IntelPresentMon/SampleClient/MetricListSample.h:8–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "../Core/source/pmon/RawFrameDataMetricList.h"
7
8int MetricListSample(std::unique_ptr<pmapi::Session> pSession)
9{
10 namespace rn = std::ranges;
11 namespace vi = rn::views;
12 auto& session = *pSession;
13
14 std::ofstream out{ "metrics.md" };
15
16 // header
17 out << "| Metric | CSV Column | Description | Compatible Query Types |\n"
18 << "| - | - | - |:-:|\n";
19
20 // get list of metrics used in CSV (as vector of query element definitions)
21 const auto csvElements = p2c::pmon::GetDefaultRawFrameDataMetricList(0, false);
22
23 // Loop through ALL PresentMon metrics
24 for (auto metric : session.GetIntrospectionRoot()->GetMetrics()) {
25 // get CSV column name if this metric is used in CSV capture file
26 std::string csvColumnName;
27 if (rn::contains(csvElements, metric.GetId(), &p2c::pmon::RawFrameQueryElementDefinition::metricId)) {
28 csvColumnName = metric.Introspect().GetName()
29 | vi::filter([](char c) { return c != ' '; })
30 | rn::to<std::basic_string>();
31 }
32 // name and description
33 out << std::format("|{}|{}|{}|",
34 metric.Introspect().GetName(),
35 csvColumnName,
36 metric.Introspect().GetDescription()
37 );
38 // query compatibility codes
39 switch (metric.GetType()) {
40 case PM_METRIC_TYPE_DYNAMIC: out << "D|\n"; break;
41 case PM_METRIC_TYPE_DYNAMIC_FRAME: out << "DF|\n"; break;
42 case PM_METRIC_TYPE_FRAME_EVENT: out << "F|\n"; break;
43 case PM_METRIC_TYPE_STATIC: out << "DS|\n"; break;
44 default: out << "|\n";
45 }
46 }
47
48 // footer
49 out << "*Query Type Codes: **D** = Dynamic Query, **F** = Frame Event Query, **S** = Static Query\n";
50
51 return 0;
52}

Callers 1

mainFunction · 0.85

Calls 8

IntrospectMethod · 0.80
GetDescriptionMethod · 0.80
GetMetricsMethod · 0.45
GetIntrospectionRootMethod · 0.45
GetIdMethod · 0.45
GetNameMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected