Skip to content

Commit 3a038cf

Browse files
committed
Add tracking for total duration and size per action in Result class
1 parent 1b40091 commit 3a038cf

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

include/filestorm/result.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class Result {
4444
enum Operation { WRITE, TRIM, OVERWRITE, READ, FALLOCATE };
4545
static std::vector<Result> results;
4646
static std::map<std::string, std::string> metas;
47+
static std::map<Action, std::chrono::nanoseconds> total_duration_per_action;
48+
static std::map<Action, DataSize<DataUnit::B>> total_size_per_action;
4749

4850
private:
4951
int _iteration;
@@ -85,7 +87,17 @@ class Result {
8587
void setExtentsCount(int64_t extents_count) { _total_extents_count = extents_count; }
8688
void setFileExtentCount(int64_t file_extent_count) { _file_extent_count = file_extent_count; }
8789

88-
void commit() { results.push_back(*this); }
90+
void commit() {
91+
results.push_back(*this);
92+
if (total_duration_per_action.find(_action) == total_duration_per_action.end()) {
93+
total_duration_per_action[_action] = std::chrono::nanoseconds(0);
94+
}
95+
if (total_size_per_action.find(_action) == total_size_per_action.end()) {
96+
total_size_per_action[_action] = DataSize<DataUnit::B>(0);
97+
}
98+
total_duration_per_action[_action] += _duration;
99+
total_size_per_action[_action] += _size;
100+
}
89101

90102
static constexpr const char* actionToString(Action action) {
91103
switch (action) {
@@ -202,6 +214,20 @@ class Result {
202214
table.format().font_align(tabulate::FontAlign::center).border_left("|").border_right("|");
203215

204216
std::cout << table << std::endl;
217+
// print total duration and total size per action
218+
std::cout << "Total Duration per Action (seconds):" << std::endl;
219+
for (const auto& action : usedActions) {
220+
if (total_duration_per_action.find(action) != total_duration_per_action.end()) {
221+
std::cout << " " << actionToString(action) << ": " << std::chrono::duration_cast<std::chrono::seconds>(total_duration_per_action[action]).count() << " s" << std::endl;
222+
}
223+
}
224+
std::cout << "Total Size per Action (MB):" << std::endl;
225+
for (const auto& action : usedActions) {
226+
if (total_size_per_action.find(action) != total_size_per_action.end()) {
227+
DataSize<DataUnit::MB> total_size_per_action_mb = total_size_per_action[action];
228+
std::cout << " " << actionToString(action) << ": " << fmt::format("{}", total_size_per_action_mb) << std::endl;
229+
}
230+
}
205231
}
206232

207233
static std::vector<Result> getActionResults(Action action) {

source/result.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ std::vector<Result> Result::results;
44

55
std::vector<BasicResult> BasicResult::results;
66

7-
std::map<std::string, std::string> Result::metas;
7+
std::map<std::string, std::string> Result::metas;
8+
9+
std::map<Result::Action, std::chrono::nanoseconds> Result::total_duration_per_action;
10+
std::map<Result::Action, DataSize<DataUnit::B>> Result::total_size_per_action;

source/scenarios/aging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void AgingScenario::run(std::unique_ptr<IOEngine>& ioengine) {
160160
rapid_aging = false;
161161
logger.debug("Rapid aging - disabling because of max time");
162162
}
163-
if (getParameter("rapid-aging-max-extents").is_set() && tree.getTotalExtents() > getParameter("rapid-aging-max-extents").get_int()) {
163+
if (getParameter("rapid-aging-max-extents").is_set() && tree.total_extents_count > getParameter("rapid-aging-max-extents").get_int()) {
164164
rapid_aging = false;
165165
logger.debug("Rapid aging - disabling because of max extents");
166166
}

0 commit comments

Comments
 (0)