From 18afd4078202f4eef77e39be0e4e326c8882e08c Mon Sep 17 00:00:00 2001 From: saundersp Date: Sat, 15 Jul 2023 03:35:31 +0200 Subject: [PATCH] cpp : disambiguated auto keyword --- cpp/ViolaJones.hpp | 8 ++++---- cpp/data.hpp | 2 +- cpp/projet.cpp | 8 ++++---- cpp/toolbox.cpp | 2 +- cpp/toolbox.hpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cpp/ViolaJones.hpp b/cpp/ViolaJones.hpp index bc04ed6..ed663cb 100644 --- a/cpp/ViolaJones.hpp +++ b/cpp/ViolaJones.hpp @@ -58,9 +58,9 @@ T benchmark_function(const char* step_name, const F& fnc, Args &&...args) noexce printf("%s...\r", step_name); fflush(stdout); // manual flush is mandatory, otherwise it will not be shown immediately because the output is buffered #endif - const auto start = time(); + const std::chrono::system_clock::time_point start = perf_counter_ns(); const T res = fnc(std::forward(args)...); - const long long timespent = duration_ns(time() - start); + const long long timespent = duration_ns(perf_counter_ns() - start); printf("| %-49s | %18s | %-29s |\n", step_name, thousand_sep(timespent).c_str(), format_time_ns(timespent).c_str()); return res; } @@ -71,9 +71,9 @@ void benchmark_function_void(const char* step_name, const F& fnc, Args &&...args printf("%s...\r", step_name); fflush(stdout); // manual flush is mandatory, otherwise it will not be shown immediately because the output is buffered #endif - const auto start = time(); + const std::chrono::system_clock::time_point start = perf_counter_ns(); fnc(std::forward(args)...); - const long long timespent = duration_ns(time() - start); + const long long timespent = duration_ns(perf_counter_ns() - start); printf("| %-49s | %18s | %-29s |\n", step_name, thousand_sep(timespent).c_str(), format_time_ns(timespent).c_str()); } diff --git a/cpp/data.hpp b/cpp/data.hpp index b4e468b..29c2c7a 100644 --- a/cpp/data.hpp +++ b/cpp/data.hpp @@ -65,7 +65,7 @@ namespace np { // #if __DEBUG // print("Shape created (initializer)"); // #endif - const auto* begin = dims.begin(); + const size_t* begin = dims.begin(); for(size_t i = 0; i < length; ++i){ data[i] = begin[i]; #if __DEBUG diff --git a/cpp/projet.cpp b/cpp/projet.cpp index 2ecd74a..f122d1d 100644 --- a/cpp/projet.cpp +++ b/cpp/projet.cpp @@ -159,17 +159,17 @@ void testing_and_evaluating(const np::Array& X_train_feat, const np::Ar const np::Array alphas = load(alphas_title); const np::Array final_classifiers = load(final_classifiers_title); - auto start = time(); + std::chrono::system_clock::time_point start = perf_counter_ns(); const np::Array y_pred_train = classify_viola_jones(alphas, final_classifiers, X_train_feat); - const long long t_pred_train = duration_ns(time() - start); + const long long t_pred_train = duration_ns(perf_counter_ns() - start); const float64_t e_acc = accuracy_score(y_train, y_pred_train); const float64_t e_f1 = f1_score(y_train, y_pred_train); float64_t e_FN, e_FP; std::tie(std::ignore, e_FN, e_FP, std::ignore) = confusion_matrix(y_train, y_pred_train); - start = time(); + start = perf_counter_ns(); const np::Array y_pred_test = classify_viola_jones(alphas, final_classifiers, X_test_feat); - const long long t_pred_test = duration_ns(time() - start); + const long long t_pred_test = duration_ns(perf_counter_ns() - start); const float64_t t_acc = accuracy_score(y_test, y_pred_test); const float64_t t_f1 = f1_score(y_test, y_pred_test); float64_t t_FN, t_FP; diff --git a/cpp/toolbox.cpp b/cpp/toolbox.cpp index ddea4b9..6dbd963 100644 --- a/cpp/toolbox.cpp +++ b/cpp/toolbox.cpp @@ -114,7 +114,7 @@ std::string thousand_sep(uint64_t k) noexcept { std::string s = "", n = std::to_string(k); uint8_t c = 0; - for (const auto& n_i : n) { + for (const char& n_i : n) { ++c; s.push_back(n_i); if (c == 3) { diff --git a/cpp/toolbox.hpp b/cpp/toolbox.hpp index e657712..ef4e76a 100644 --- a/cpp/toolbox.hpp +++ b/cpp/toolbox.hpp @@ -4,7 +4,7 @@ #include #define duration_ns(a) std::chrono::duration_cast(a).count() -#define time() std::chrono::high_resolution_clock::now() +#define perf_counter_ns() std::chrono::high_resolution_clock::now() std::string format_time(uint64_t) noexcept; std::string format_time_ns(uint64_t) noexcept;