libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
webasm_timebase.hpp
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5
6#include "timebase.hpp"
7
8namespace LibXR
9{
10
15{
16 public:
18 {
19 // 初始化基准时间点
20 start_time_ = std::chrono::system_clock::now();
21 }
22
28 {
29 auto now = std::chrono::system_clock::now();
30 auto us =
31 std::chrono::duration_cast<std::chrono::microseconds>(now - start_time_).count();
32 return static_cast<MicrosecondTimestamp>(us % UINT32_MAX);
33 }
34
40 {
41 auto now = std::chrono::system_clock::now();
42 auto ms =
43 std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time_).count();
44 return static_cast<MillisecondTimestamp>(ms % UINT32_MAX);
45 }
46
47 private:
48 std::chrono::system_clock::time_point start_time_;
49};
50
51} // namespace LibXR
表示微秒级时间戳的类。Class representing a timestamp in microseconds.
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
时间基类,用于提供高精度时间戳。 Timebase class for providing high-precision timestamps.
Definition timebase.hpp:18
WebAsmTimebase 类,用于获取 WebAssembly 系统的时间基准。
MillisecondTimestamp _get_milliseconds() override
获取当前时间戳(毫秒级)
MicrosecondTimestamp _get_microseconds() override
获取当前时间戳(微秒级)
LibXR 命名空间
Definition ch32_gpio.hpp:9