mirror of
https://github.com/deepinsight/insightface.git
synced 2025-12-30 08:02:27 +00:00
updating benchmark
This commit is contained in:
54
cpp-package/inspireface/cpp/inspireface/cost_time.h
Normal file
54
cpp-package/inspireface/cpp/inspireface/cost_time.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef COST_TIME_HPP
|
||||
#define COST_TIME_HPP
|
||||
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include "log.h" // Assume log.h includes the INSPIRE_LOGI macro
|
||||
|
||||
// Macro definition to control whether time cost calculations are enabled
|
||||
#ifdef ISF_ENABLE_COST_TIME
|
||||
|
||||
#define COST_TIME(id, precision) inspire::CostTime cost_time_##id(#id, __FILENAME__, __FUNCTION__, __LINE__, precision)
|
||||
#define COST_TIME_SIMPLE(id) inspire::CostTime cost_time_##id(#id, __FILENAME__, __FUNCTION__, __LINE__)
|
||||
|
||||
#else
|
||||
#define COST_TIME(id, precision) // No operation, when ISF_ENABLE_COST_TIME is not defined
|
||||
#define COST_TIME_SIMPLE(id) // No operation, when ISF_ENABLE_COST_TIME is not defined
|
||||
|
||||
#endif
|
||||
|
||||
namespace inspire {
|
||||
|
||||
class CostTime {
|
||||
public:
|
||||
// Constructor, records the start time
|
||||
explicit CostTime(const char* id, const char* filename, const char* function, int line, int precision = 5)
|
||||
: id_(id), filename_(filename), function_(function), line_(line), precision_(precision),
|
||||
start_time_(std::chrono::steady_clock::now()) {}
|
||||
|
||||
// Destructor, calculates and logs the time taken
|
||||
~CostTime() {
|
||||
auto end_time = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> duration = end_time - start_time_;
|
||||
|
||||
// Use a string stream for formatted output, controlling decimal precision
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::setprecision(precision_) << duration.count();
|
||||
|
||||
// Log the time cost
|
||||
INSPIRE_LOGI("CostTime: [%s] %s:%d %s took %s seconds", id_, filename_, line_, function_, oss.str().c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
const char* id_;
|
||||
const char* filename_;
|
||||
const char* function_;
|
||||
int line_;
|
||||
int precision_;
|
||||
std::chrono::time_point<std::chrono::steady_clock> start_time_;
|
||||
};
|
||||
|
||||
} // namespace inspire
|
||||
|
||||
#endif // COST_TIME_HPP
|
||||
@@ -16,7 +16,18 @@ The benchmark tests will be continuously updated.
|
||||
| Face Extract(**MNet**) | 1000 | 853ms | **0.85ms** |
|
||||
| Face Extract(**R50**) | 1000 | 3856ms | **3.86ms** |
|
||||
|
||||
**Note: **The above data inference backend uses CoreML.
|
||||
### Device: Mac mini 2023 , Apple M2
|
||||
| **Benchmark** | **Loops** | **Total Time** | **Average Time** |
|
||||
| ---------------------- | --------- | -------------- | ---------------- |
|
||||
| Face Detect@160 | 1000 | 414 ms | **0.45 ms** |
|
||||
| Face Detect@192 | 1000 | 574ms | **0.57ms** |
|
||||
| Face Detect@256 | 1000 | 769ms | **0.77ms** |
|
||||
| Face Detect@320 | 1000 | 1073ms | **1.07ms** |
|
||||
| Face Detect@640 | 1000 | 3743ms | **3.74ms** |
|
||||
| Face Extract(**MNet**) | 1000 | 573ms | **0.57ms** |
|
||||
| Face Extract(**R50**) | 1000 | 3527ms | **3.53ms** |
|
||||
|
||||
**Note**: The above data inference backend uses CoreML.
|
||||
|
||||
## Pikachu
|
||||
### Device: Macbook pro 16-inch, 2019 2.6 GHz Intel Core i7
|
||||
|
||||
Reference in New Issue
Block a user