2023-01-05 01:52:56 -05:00
|
|
|
/*
|
|
|
|
* Created by Brett on 04/01/23.
|
|
|
|
* Licensed under GNU General Public License V3.0
|
|
|
|
* See LICENSE file for license detail
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLT_SYSTEM_H
|
|
|
|
#define BLT_SYSTEM_H
|
|
|
|
|
2023-12-16 02:37:24 -05:00
|
|
|
#ifndef __EMSCRIPTEN__
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <intrin.h>
|
|
|
|
#else
|
|
|
|
#include <x86intrin.h>
|
|
|
|
#endif
|
2023-10-03 00:43:08 -04:00
|
|
|
#else
|
2023-12-16 02:37:24 -05:00
|
|
|
#include <chrono>
|
2023-10-03 00:43:08 -04:00
|
|
|
#endif
|
|
|
|
#include <cstdint>
|
|
|
|
|
2023-02-11 12:53:32 -05:00
|
|
|
namespace blt::system {
|
2023-10-03 00:43:08 -04:00
|
|
|
//#ifdef __GNUC__
|
|
|
|
// #define GNU_INLINE __attribute__((__gnu_inline__, __always_inline__))
|
|
|
|
//#else
|
|
|
|
// #define GNU_INLINE
|
|
|
|
//#endif
|
|
|
|
inline std::uint64_t rdtsc(){
|
2023-12-16 02:37:24 -05:00
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
|
|
|
#else
|
2023-10-03 00:43:08 -04:00
|
|
|
return __rdtsc();
|
2023-12-16 02:37:24 -05:00
|
|
|
#endif
|
2023-10-03 00:43:08 -04:00
|
|
|
}
|
2023-01-05 01:52:56 -05:00
|
|
|
// TODO: system memory and current CPU usage. (Linux Only currently)
|
2023-11-22 21:21:17 -05:00
|
|
|
|
2023-01-05 01:52:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //BLT_SYSTEM_H
|