Skip to content

Commit 0a46cb7

Browse files
committed
Add stats for flash
1 parent 117721a commit 0a46cb7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Cmd_Flash.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "PICoBoot_Utility.hpp"
2121

22+
#include <chrono>
23+
2224
int Command_Flash(const std::vector<std::string>& args) {
2325
if (args.size() != 2) {
2426
puts("error: no file specified");
@@ -56,6 +58,7 @@ int Command_Flash(const std::vector<std::string>& args) {
5658
size_t infile_size = infile.tellg();
5759
infile.seekg(0, std::ios_base::beg);
5860
size_t processed_size = 0;
61+
size_t byte_count = 0;
5962

6063
std::string line;
6164

@@ -112,19 +115,23 @@ int Command_Flash(const std::vector<std::string>& args) {
112115
}
113116

114117

115-
118+
byte_count += len;
116119
cnt++;
117120
}
118121
};
119122

120-
puts("");
123+
auto time_start = std::chrono::high_resolution_clock::now();
121124

122125
while (std::getline(infile, line)) {
123126
dec.read(line);
124127
processed_size += line.size();
125128
}
126129

130+
auto time_end = std::chrono::high_resolution_clock::now();
131+
auto duration = (double)std::chrono::duration_cast<std::chrono::microseconds>(time_end - time_start).count() / 1000000;
132+
127133
printf("\033[2K\rFlashing ... [0x%08x] %zu/%zu %.2f%%\n", last_addr, infile_size, infile_size, (float)100);
134+
printf("%zu bytes written in %.3f seconds, %zu bytes/sec\n", byte_count, duration, (size_t)(byte_count / duration));
128135

129136
return 0;
130137
}

0 commit comments

Comments
 (0)