-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1196 from Sonicadvance1/offline_telemetry
Implements support for offline *only* telemetry
- Loading branch information
Showing
12 changed files
with
230 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
#include "Common/Paths.h" | ||
|
||
#include <FEXCore/Config/Config.h> | ||
#include <FEXCore/Utils/LogManager.h> | ||
#include <FEXCore/Utils/Telemetry.h> | ||
|
||
#include <array> | ||
#include <filesystem> | ||
#include <fstream> | ||
|
||
namespace FEXCore::Telemetry { | ||
#ifndef FEX_DISABLE_TELEMETRY | ||
static std::array<Value, FEXCore::Telemetry::TelemetryType::TYPE_LAST> TelemetryValues = {{ }}; | ||
const std::array<std::string, FEXCore::Telemetry::TelemetryType::TYPE_LAST> TelemetryNames { | ||
"64byte Split Locks", | ||
"16Byte Split atomics", | ||
"VEX instructions (AVX)", | ||
"EVEX instructions (AVX512)", | ||
}; | ||
void Initialize() { | ||
auto DataDirectory = Config::GetDataDirectory(); | ||
DataDirectory += "Telemetry/"; | ||
|
||
// Ensure the folder structure is created for our configuration | ||
std::error_code ec{}; | ||
if (!std::filesystem::exists(DataDirectory, ec) && | ||
!std::filesystem::create_directories(DataDirectory, ec)) { | ||
LogMan::Msg::I("Couldn't create telemetry Folder"); | ||
} | ||
} | ||
|
||
void Shutdown(std::filesystem::path &ApplicationName) { | ||
auto DataDirectory = Config::GetDataDirectory(); | ||
DataDirectory += "Telemetry/" + ApplicationName.string() + ".telem"; | ||
|
||
std::error_code ec{}; | ||
if (std::filesystem::exists(DataDirectory, ec)) { | ||
// If the file exists, retain a single backup | ||
auto Backup = DataDirectory + ".1"; | ||
std::filesystem::copy_file(DataDirectory, Backup, std::filesystem::copy_options::overwrite_existing, ec); | ||
} | ||
|
||
std::fstream fs(DataDirectory, std::ios_base::out | std::ios_base::trunc); | ||
if (fs.is_open()) { | ||
for (size_t i = 0; i < TelemetryType::TYPE_LAST; ++i) { | ||
auto &Name = TelemetryNames.at(i); | ||
auto &Data = TelemetryValues.at(i); | ||
fs << Name << ": " << *Data << std::endl; | ||
} | ||
|
||
fs.flush(); | ||
fs.close(); | ||
} | ||
} | ||
|
||
Value &GetObject(TelemetryType Type) { | ||
return TelemetryValues.at(Type); | ||
} | ||
#endif | ||
} |
Oops, something went wrong.