better naming conventions for stopwatch procedures + fields

This commit is contained in:
Phil H
2021-10-28 14:08:21 -07:00
parent bbccf9ddbf
commit e4ce017183
+10 -10
View File
@@ -46,31 +46,31 @@ Weekday :: enum int {
Stopwatch :: struct { Stopwatch :: struct {
running: bool, running: bool,
_start_time: Tick, _start_time: Tick,
_stop_time: Duration, _accumulation: Duration,
} }
start :: proc(using stopwatch: ^Stopwatch) { stopwatch_start :: proc(using stopwatch: ^Stopwatch) {
if !running { if !running {
_start_time = tick_now() _start_time = tick_now()
running = true running = true
} }
} }
stop :: proc(using stopwatch: ^Stopwatch) { stopwatch_stop :: proc(using stopwatch: ^Stopwatch) {
if running { if running {
_stop_time += tick_diff(_start_time, tick_now()) _accumulation += tick_diff(_start_time, tick_now())
running = false running = false
} }
} }
reset :: proc(using stopwatch: ^Stopwatch) { stopwatch_reset :: proc(using stopwatch: ^Stopwatch) {
_stop_time = {} _accumulation = {}
running = false running = false
} }
duration :: proc(using stopwatch: Stopwatch) -> Duration { stopwatch_duration :: proc(using stopwatch: Stopwatch) -> Duration {
if !running { return _stop_time } if !running { return _accumulation }
return _stop_time + tick_diff(_start_time, tick_now()) return _accumulation + tick_diff(_start_time, tick_now())
} }
diff :: proc(start, end: Time) -> Duration { diff :: proc(start, end: Time) -> Duration {
@@ -171,7 +171,7 @@ clock_from_duration :: proc(d: Duration) -> (hour, min, sec: int) {
} }
clock_from_stopwatch :: proc(s: Stopwatch) -> (hour, min, sec: int) { clock_from_stopwatch :: proc(s: Stopwatch) -> (hour, min, sec: int) {
return clock_from_duration(duration(s)) return clock_from_duration(stopwatch_duration(s))
} }
clock_from_seconds :: proc(nsec: u64) -> (hour, min, sec: int) { clock_from_seconds :: proc(nsec: u64) -> (hour, min, sec: int) {