| 29 | } |
| 30 | |
| 31 | static void initThresholdFile(const std::string& filename = "thresholds.json") { |
| 32 | std::lock_guard<std::mutex> lock(thresholdFileMutex); |
| 33 | |
| 34 | if (thresholdFile.is_open()) { |
| 35 | thresholdFile.close(); |
| 36 | } |
| 37 | |
| 38 | currentThresholdFile = filename; |
| 39 | thresholdFile.open(filename, std::ios::out); |
| 40 | if (thresholdFile.is_open()) { |
| 41 | thresholdFile << "{\n"; |
| 42 | thresholdFile.flush(); |
| 43 | isFirstThreshold = true; |
| 44 | MNN_PRINT("Initialized threshold file: %s\n", filename.c_str()); |
| 45 | } else { |
| 46 | MNN_ERROR("Failed to open threshold file: %s\n", filename.c_str()); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | static void writeThresholdRealtime(const std::string& opName, float thresholdValue) { |
| 51 | std::lock_guard<std::mutex> lock(thresholdFileMutex); |
no test coverage detected