21#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
25# include <x86intrin.h>
34 __int64 frequency, counter;
36 QueryPerformanceFrequency((LARGE_INTEGER *)&frequency);
37 QueryPerformanceCounter((LARGE_INTEGER *)&counter);
39 return (
double)counter / (double)frequency;
44 Sleep((
int)(t * 1000));
50 gettimeofday(&now,
nullptr);
52 return now.tv_sec + now.tv_usec * 1
e-6;
69 const int us = (int)(t * 1e6);
76#if defined(__aarch64__) || defined(_M_ARM64)
81# if defined(ARCH_COMPILER_MSVC)
82 return _ReadStatusReg(ARM64_CNTVCT_EL0);
85 asm(
"mrs %x0, cntvct_el0" :
"=r"(counter));
91# if defined(ARCH_COMPILER_MSVC)
92 return _ReadStatusReg(ARM64_CNTFRQ_EL0);
95 asm(
"mrs %x0, cntfrq_el0" :
"=r"(freq));
99#elif defined(__x86_64__) || defined(_M_X64)
104 return __rdtscp(last_cpu);
116 double start_precise =
time_dt();
119 double end_precise =
time_dt();
120 frequency =
uint64_t(
double(end_tick - start_tick) / (end_precise - start_precise));
131 auto now = std::chrono::steady_clock::now();
132 auto nanoseconds = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
133 return nanoseconds.time_since_epoch().count();
145 const int h = (((int)seconds) / (60 * 60));
146 const int m = (((int)seconds) / 60) % 60;
147 const int s = (((int)seconds) % 60);
148 const int r = (((int)(seconds * 100)) % 100);
161 const int multipliers[] = {1, 60, 60 * 60, 24 * 60 * 60};
162 const int num_multiplies =
sizeof(multipliers) /
sizeof(*multipliers);
163 if (time_string.empty()) {
170 const int num_fraction_tokens = fraction_tokens.size();
171 if (num_fraction_tokens == 0) {
175 if (fraction_tokens.size() == 1) {
179 else if (fraction_tokens.size() == 2) {
180 result = atof(fraction_tokens[1].c_str());
191 const int num_tokens = tokens.size();
192 if (num_tokens > num_multiplies) {
196 for (
int i = 0;
i < num_tokens; ++
i) {
197 result += atoi(tokens[num_tokens -
i - 1].c_str()) * multipliers[
i];
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
unsigned long long int uint64_t
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
void string_split(vector< string > &tokens, const string &str, const string &separators, bool skip_empty_tokens)
uint64_t time_fast_frequency()
uint64_t time_fast_tick(uint32_t *)
void time_sleep(double t)
double time_human_readable_to_seconds(const string &time_string)
string time_human_readable_from_seconds(const double seconds)
CCL_NAMESPACE_BEGIN double time_dt()