P4C
The P4 Compiler
Loading...
Searching...
No Matches
exportMetrics.h
1/*
2Exports the collected code metric values into a formatted
3text file, and a json file. The new filenames are based on the
4compiled program name (programName_metrics.txt/json).
5*/
6
7#ifndef FRONTENDS_P4_METRICS_EXPORTMETRICS_H_
8#define FRONTENDS_P4_METRICS_EXPORTMETRICS_H_
9
10#include <cmath>
11#include <filesystem>
12#include <fstream>
13#include <iostream>
14#include <string>
15#include <unordered_set>
16
17#include "frontends/p4/metrics/metricsStructure.h"
18#include "ir/ir.h"
19#include "lib/json.h"
20
21using namespace P4::literals;
22
23namespace P4 {
24
25class ExportMetricsPass : public Inspector {
26 private:
27 std::filesystem::path filename;
28 std::set<cstring> selectedMetrics;
29 Metrics &metrics;
30
31 public:
32 explicit ExportMetricsPass(const std::filesystem::path &filename,
33 std::set<cstring> selectedMetrics, Metrics &metricsRef)
34 : filename(filename), selectedMetrics(selectedMetrics), metrics(metricsRef) {
35 setName("ExportMetricsPass");
36 }
37 bool preorder(const IR::P4Program * /*program*/) override;
38};
39
40} // namespace P4
41
42#endif /* FRONTENDS_P4_METRICS_EXPORTMETRICS_H_ */
Definition visitor.h:413
Definition cstring.h:80
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition metricsStructure.h:119