@@ -47,37 +47,56 @@ inline double measureSizeDifference(const IR::P4Program &programBefore,
47
47
struct FlayServiceStatistics : public AnalysisStatistics {
48
48
FlayServiceStatistics (const IR::P4Program *optimizedProgram, uint64_t statementCountBefore,
49
49
uint64_t statementCountAfter, size_t cyclomaticComplexity,
50
- size_t numParsersPaths)
50
+ size_t numParsersPaths, size_t numUpdatesProcessed,
51
+ size_t numRespecializations)
51
52
: optimizedProgram(optimizedProgram),
52
53
statementCountBefore (statementCountBefore),
53
54
statementCountAfter(statementCountAfter),
54
55
cyclomaticComplexity(cyclomaticComplexity),
55
- numParsersPaths(numParsersPaths) {}
56
+ numParsersPaths(numParsersPaths),
57
+ numUpdatesProcessed(numUpdatesProcessed),
58
+ numRespecializations(numRespecializations) {}
56
59
57
- // The optimized program.
60
+ // / The optimized program.
58
61
const IR::P4Program *optimizedProgram;
59
- // The number of statements in the original program.
62
+ // / The number of statements in the original program.
60
63
uint64_t statementCountBefore;
61
- // The number of statements in the optimized program.
64
+ // / The number of statements in the optimized program.
62
65
uint64_t statementCountAfter;
63
- // The cyclomatic complexity of the input program.
66
+ // / The cyclomatic complexity of the input program.
64
67
size_t cyclomaticComplexity;
65
- // The total number of paths for parsers
68
+ // / The total number of paths for parsers
66
69
size_t numParsersPaths;
70
+ // / The total number of updates processed.
71
+ size_t numUpdatesProcessed = 0 ;
72
+ // / The total number of times a respecialization was necessary.
73
+ size_t numRespecializations = 0 ;
67
74
68
75
[[nodiscard]] std::string toFormattedString () const override {
69
76
std::stringstream output;
70
77
output << " \n statement_count_before:" << statementCountBefore << " \n " ;
71
78
output << " statement_count_after:" << statementCountAfter << " \n " ;
72
79
output << " cyclomatic_complexity:" << cyclomaticComplexity << " \n " ;
73
80
output << " num_parsers_paths:" << numParsersPaths << " \n " ;
81
+ output << " num_updates_processed:" << numUpdatesProcessed << " \n " ;
82
+ output << " num_respecializations:" << numRespecializations << " \n " ;
74
83
return output.str ();
75
84
}
76
85
77
86
DECLARE_TYPEINFO (FlayServiceStatistics);
78
87
};
79
88
89
+ // / Maps a particular specialization category to its statistics.
90
+ using FlayServiceStatisticsMap = ordered_map<std::string, AnalysisStatistics *>;
91
+
80
92
class FlayServiceBase {
93
+ private:
94
+ // / Number of updates processed.
95
+ size_t _updateCount = 0 ;
96
+
97
+ // / Number of times respecialization was necessary.
98
+ size_t _respecializationCount = 0 ;
99
+
81
100
protected:
82
101
// / The incremental analysis.
83
102
IncrementalAnalysisMap _incrementalAnalysisMap;
@@ -94,6 +113,12 @@ class FlayServiceBase {
94
113
95
114
int specializeProgram ();
96
115
116
+ // / Return the number of updates processed.
117
+ [[nodiscard]] size_t updateCount () const { return _updateCount; }
118
+
119
+ // / Return the number of times respecialization was necessary.
120
+ [[nodiscard]] size_t respecializationCount () const { return _respecializationCount; }
121
+
97
122
public:
98
123
explicit FlayServiceBase (const FlayCompilerResult &compilerResult,
99
124
IncrementalAnalysisMap incrementalAnalysisMap);
@@ -121,7 +146,7 @@ class FlayServiceBase {
121
146
const std::vector<const ControlPlaneUpdate *> &controlPlaneUpdates);
122
147
123
148
// / Compute and return some statistics on the changes in the program.
124
- [[nodiscard]] std::vector<AnalysisStatistics *> computeFlayServiceStatistics () const ;
149
+ [[nodiscard]] FlayServiceStatisticsMap computeFlayServiceStatistics () const ;
125
150
};
126
151
127
152
} // namespace P4::P4Tools::Flay
0 commit comments