argparse get_cast update to work with all is_arithmetic types
parent
7a07f4a729
commit
0b907867a2
|
@ -375,18 +375,22 @@ namespace blt
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<T, arg_data_vec_t>)
|
if constexpr (std::is_same_v<T, arg_data_vec_t>)
|
||||||
return std::get<arg_data_vec_t>(v);
|
return std::get<arg_data_vec_t>(v);
|
||||||
else
|
|
||||||
{
|
|
||||||
auto t = std::get<arg_data_internal_t>(v);
|
auto t = std::get<arg_data_internal_t>(v);
|
||||||
// user is requesting an int, but holds a string, we are going to make the assumption the data can be converted
|
// user is requesting an int, but holds a string, we are going to make the assumption the data can be converted
|
||||||
// it is up to the user to deal with the variant if they do not want this behaviour!
|
// it is up to the user to deal with the variant if they do not want this behaviour!
|
||||||
if constexpr (std::is_same_v<int32_t, T>)
|
if constexpr (!std::is_arithmetic_v<T>)
|
||||||
{
|
|
||||||
if (std::holds_alternative<std::string>(t))
|
|
||||||
return std::stoi(std::get<std::string>(t));
|
|
||||||
}
|
|
||||||
return std::get<T>(t);
|
return std::get<T>(t);
|
||||||
}
|
// ugly!
|
||||||
|
if (std::holds_alternative<int32_t>(t))
|
||||||
|
return static_cast<T>(std::get<int32_t>(t));
|
||||||
|
if (std::holds_alternative<bool>(t))
|
||||||
|
return static_cast<T>(std::get<bool>(t));
|
||||||
|
auto s = std::get<std::string>(t);
|
||||||
|
if constexpr (std::is_floating_point_v<T>)
|
||||||
|
return static_cast<T>(std::stod(s));
|
||||||
|
if constexpr (std::is_signed_v<T>)
|
||||||
|
return static_cast<T>(std::stoll(s));
|
||||||
|
return static_cast<T>(std::stoull(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3
|
Subproject commit 77cab8192a879e5d27188f97e8f2080dd7e36ca8
|
|
@ -148,7 +148,7 @@ namespace blt::profiling {
|
||||||
void startInterval(const std::string& profileName, const std::string& intervalName) {
|
void startInterval(const std::string& profileName, const std::string& intervalName) {
|
||||||
std::scoped_lock lock(profileLock);
|
std::scoped_lock lock(profileLock);
|
||||||
capture_interval interval{};
|
capture_interval interval{};
|
||||||
interval.start = system::getCurrentTimeNanoseconds();
|
interval.start = system::getCPUThreadTime();
|
||||||
profiles[profileName].intervals[intervalName] = interval;
|
profiles[profileName].intervals[intervalName] = interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace blt::profiling {
|
||||||
auto& prof = profiles[profileName];
|
auto& prof = profiles[profileName];
|
||||||
auto& ref = prof.intervals[intervalName];
|
auto& ref = prof.intervals[intervalName];
|
||||||
|
|
||||||
ref.end = system::getCurrentTimeNanoseconds();
|
ref.end = system::getCPUThreadTime();
|
||||||
|
|
||||||
auto difference = ref.end - ref.start;
|
auto difference = ref.end - ref.start;
|
||||||
auto& href = prof.intervals_total[intervalName];
|
auto& href = prof.intervals_total[intervalName];
|
||||||
|
@ -169,7 +169,7 @@ namespace blt::profiling {
|
||||||
void point(const std::string& profileName, const std::string& pointName) {
|
void point(const std::string& profileName, const std::string& pointName) {
|
||||||
std::scoped_lock lock(profileLock);
|
std::scoped_lock lock(profileLock);
|
||||||
capture_point point{};
|
capture_point point{};
|
||||||
point.point = system::getCurrentTimeNanoseconds();
|
point.point = system::getCPUThreadTime();
|
||||||
point.name = pointName;
|
point.name = pointName;
|
||||||
profiles[profileName].points.push(point);
|
profiles[profileName].points.push(point);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue