mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[wpiutil] Upgrade to fmt 10.2.1, add wpi::print (#6161)
We now use a wrapper (wpi::print) to catch exceptions since we can't patch std::print() to not throw when we ultimately migrate to it. fmtlib and std format/print throw the same exceptions and always have. We previously patched fmt::print() to not throw a write failure exception, but we can't do that for std::print(); wpi::print() is the migration plan.
This commit is contained in:
@@ -8,9 +8,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "wpi/DataLog.h"
|
||||
#include "wpi/print.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
using std::chrono::duration_cast;
|
||||
@@ -66,7 +65,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
for (const auto& [name, fn] : testVec) {
|
||||
auto resVec = std::vector<microseconds::rep>();
|
||||
fmt::print("{}: ", name);
|
||||
wpi::print("{}: ", name);
|
||||
|
||||
for (int i = 0; i < kNumRuns; ++i) {
|
||||
auto start = high_resolution_clock::now();
|
||||
@@ -75,7 +74,7 @@ int main(int argc, char** argv) {
|
||||
resVec.push_back(duration_cast<microseconds>(stop - start).count());
|
||||
}
|
||||
|
||||
fmt::print("{}us\n",
|
||||
wpi::print("{}us\n",
|
||||
std::accumulate(resVec.begin(), resVec.end(), 0) / kNumRuns);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user