package core:time
Index
Constants (25)
- ABSOLUTE_TO_INTERNAL
- ABSOLUTE_TO_UNIX
- ABSOLUTE_ZERO_YEAR
- DAYS_PER_100_YEARS
- DAYS_PER_400_YEARS
- DAYS_PER_4_YEARS
- Hour
- INTERNAL_TO_ABSOLUTE
- INTERNAL_TO_UNIX
- INTERNAL_TO_WALL
- IS_SUPPORTED
- MAX_DURATION
- MIN_DURATION
- Microsecond
- Millisecond
- Minute
- Nanosecond
- SECONDS_PER_DAY
- SECONDS_PER_HOUR
- SECONDS_PER_MINUTE
- SECONDS_PER_WEEK
- Second
- UNIX_TO_ABSOLUTE
- UNIX_TO_INTERNAL
- WALL_TO_INTERNAL
Variables (1)
Procedures (39)
- SCOPED_TICK_DURATION
- accurate_sleep
- benchmark
- clock_from_duration
- clock_from_seconds
- clock_from_stopwatch
- clock_from_time
- date
- datetime_to_time
- day
- diff
- duration_hours
- duration_microseconds
- duration_milliseconds
- duration_minutes
- duration_nanoseconds
- duration_round
- duration_seconds
- duration_truncate
- month
- now
- read_cycle_counter
- since
- sleep
- stopwatch_duration
- stopwatch_reset
- stopwatch_start
- stopwatch_stop
- tick_diff
- tick_lap_time
- tick_now
- tick_since
- time_add
- time_to_unix
- time_to_unix_nano
- to_unix_nanoseconds
- to_unix_seconds
- unix
- year
Procedure Groups (1)
Types
Benchmark_Error ¶
Benchmark_Error :: enum int { Okay = 0, Allocation_Error, }
Benchmark_Options ¶
Benchmark_Options :: struct { setup: proc "odin" (options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error), bench: proc "odin" (options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error), teardown: proc "odin" (options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error), rounds: int, bytes: int, input: []u8, count: int, processed: int, output: []u8, // Unused for hash benchmarks hash: u128, // Performance duration: Duration, rounds_per_second: f64, megabytes_per_second: f64, }
Duration ¶
Duration :: distinct i64
Month ¶
Month :: enum int { January = 1, February, March, April, May, June, July, August, September, October, November, December, }
Constants
ABSOLUTE_TO_INTERNAL ¶
ABSOLUTE_TO_INTERNAL :: i64(-9223371966579724800)
ABSOLUTE_TO_UNIX ¶
ABSOLUTE_TO_UNIX: i64 : -UNIX_TO_ABSOLUTE
ABSOLUTE_ZERO_YEAR ¶
ABSOLUTE_ZERO_YEAR :: i64(-292277022399)
DAYS_PER_100_YEARS ¶
DAYS_PER_100_YEARS :: 365 * 100 + 24
DAYS_PER_400_YEARS ¶
DAYS_PER_400_YEARS :: 365 * 400 + 97
DAYS_PER_4_YEARS ¶
DAYS_PER_4_YEARS :: 365 * 4 + 1
INTERNAL_TO_ABSOLUTE ¶
INTERNAL_TO_ABSOLUTE: i64 : -ABSOLUTE_TO_INTERNAL
INTERNAL_TO_UNIX ¶
INTERNAL_TO_UNIX: i64 : -UNIX_TO_INTERNAL
INTERNAL_TO_WALL ¶
INTERNAL_TO_WALL: i64 : -WALL_TO_INTERNAL
IS_SUPPORTED ¶
IS_SUPPORTED :: _IS_SUPPORTED
MAX_DURATION ¶
MAX_DURATION :: Duration(1 << 63 - 1)
MIN_DURATION ¶
MIN_DURATION :: Duration(-1 << 63)
Microsecond ¶
Microsecond: Duration : 1000 * Nanosecond
Millisecond ¶
Millisecond: Duration : 1000 * Microsecond
Nanosecond ¶
Nanosecond :: Duration(1)
SECONDS_PER_DAY ¶
SECONDS_PER_DAY :: 24 * SECONDS_PER_HOUR
SECONDS_PER_HOUR ¶
SECONDS_PER_HOUR :: 60 * SECONDS_PER_MINUTE
SECONDS_PER_MINUTE ¶
SECONDS_PER_MINUTE :: 60
SECONDS_PER_WEEK ¶
SECONDS_PER_WEEK :: 7 * SECONDS_PER_DAY
UNIX_TO_ABSOLUTE ¶
UNIX_TO_ABSOLUTE: i64 : UNIX_TO_INTERNAL + INTERNAL_TO_ABSOLUTE
UNIX_TO_INTERNAL ¶
UNIX_TO_INTERNAL :: i64((1969 * 365 + 1969 / 4 - 1969 / 100 + 1969 / 400) * SECONDS_PER_DAY)
WALL_TO_INTERNAL ¶
WALL_TO_INTERNAL :: i64((1884 * 365 + 1884 / 4 - 1884 / 100 + 1884 / 400) * SECONDS_PER_DAY)
Variables
days_before ¶
days_before: [13]i32 = …
Procedures
accurate_sleep ¶
accurate_sleep :: proc "contextless" (d: Duration) {…}
Accurate sleep borrowed from: https://blat-blatnik.github.io/computerBear/making-accurate-sleep-function/
Accuracy seems to be pretty good out of the box on Linux, to within around 4µs worst case.
On Windows it depends but is comparable with regular sleep in the worst case.
To get the same kind of accuracy as on Linux, have your program call win32.time_begin_period(1)
to
tell Windows to use a more accurate timer for your process.
benchmark ¶
benchmark :: proc "odin" (options: ^Benchmark_Options, allocator := context.allocator) -> (err: Benchmark_Error) {…}
clock_from_duration ¶
clock_from_duration :: proc "contextless" (d: Duration) -> (hour, min, sec: int) {…}
clock_from_seconds ¶
clock_from_seconds :: proc "contextless" (nsec: u64) -> (hour, min, sec: int) {…}
clock_from_stopwatch ¶
clock_from_stopwatch :: proc "contextless" (s: Stopwatch) -> (hour, min, sec: int) {…}
clock_from_time ¶
clock_from_time :: proc "contextless" (t: Time) -> (hour, min, sec: int) {…}
datetime_to_time ¶
datetime_to_time :: proc "contextless" ( year, month, day, hour, minute, second: int, ) -> (t: Time, ok: bool) {…}
duration_hours ¶
duration_hours :: proc "contextless" (d: Duration) -> f64 {…}
duration_microseconds ¶
duration_microseconds :: proc "contextless" (d: Duration) -> f64 {…}
duration_milliseconds ¶
duration_milliseconds :: proc "contextless" (d: Duration) -> f64 {…}
duration_minutes ¶
duration_minutes :: proc "contextless" (d: Duration) -> f64 {…}
duration_nanoseconds ¶
duration_nanoseconds :: proc "contextless" (d: Duration) -> i64 {…}
duration_seconds ¶
duration_seconds :: proc "contextless" (d: Duration) -> f64 {…}
read_cycle_counter ¶
read_cycle_counter :: proc "contextless" () -> u64 {…}
stopwatch_reset ¶
stopwatch_reset :: proc "contextless" (using stopwatch: ^Stopwatch) {…}
stopwatch_start ¶
stopwatch_start :: proc "contextless" (using stopwatch: ^Stopwatch) {…}
stopwatch_stop ¶
stopwatch_stop :: proc "contextless" (using stopwatch: ^Stopwatch) {…}
tick_now ¶
tick_now :: proc "contextless" () -> Tick {…}
time_to_unix ¶
time_to_unix :: proc "contextless" (t: Time) -> i64 {…}
time_to_unix_nano ¶
time_to_unix_nano :: proc "contextless" (t: Time) -> i64 {…}
to_unix_nanoseconds ¶
to_unix_nanoseconds :: time_to_unix_nano
to_unix_seconds ¶
to_unix_seconds :: time_to_unix
Procedure Groups
clock ¶
clock :: proc{ clock_from_time, clock_from_duration, clock_from_stopwatch, }
Source Files
Generation Information
Generated with odin version dev-2023-01 (vendor "odin") Windows_amd64 @ 2023-01-15 21:08:15.378908600 +0000 UTC