Documentation
¶
Overview ¶
Package vrtime defines and manages virtual time inside a simulator. Time is tracked as an integral number of ticks since the epoch, along with a secondary sort value to provide for deterministic order among simultaneous events.
Index ¶
- Variables
- func MuSecondsToTicks(v float64) int64
- func SecondsToTicks(v float64) int64
- func SetTicksPerSecond(tps int64) bool
- func TicksToSeconds(ticks int64) float64
- func TimeToSeconds(t Time) float64
- type Time
- func (t Time) EQ(t1 Time) bool
- func (t Time) GE(t1 Time) bool
- func (t Time) GT(t1 Time) bool
- func (t Time) LE(t1 Time) bool
- func (t Time) LT(t1 Time) bool
- func (t Time) NEQ(t1 Time) bool
- func (t Time) Plus(a Time) Time
- func (t *Time) Pri() int64
- func (t Time) Seconds() float64
- func (t *Time) SecondsStr() string
- func (t *Time) SetPri(p int64)
- func (t *Time) SetTicks(v int64)
- func (t Time) Ticks() int64
- func (t *Time) TimeStr() string
Constants ¶
This section is empty.
Variables ¶
var FloatTicksPerSecond float64 = float64(TicksPerSecond)
FloatTicksPerSecond gives a float64 representation of the size of number of ticks a second has
var NanoSecPerTick int64 = int64((float64(1e9)) * SecondPerTick)
NanoSecPerTick gives a float64 representation of the tick size in nanoseconds
var SecondPerTick float64 = 1e-10
SecondPerTick gives a float64 representation of the tick size in seconds. Default 0.1 ns
var TickValue float64 = SecondPerTick
TickValue gives the size of a tick, in seconds
var TicksPerSecond int64 = int64(1.0 / SecondPerTick)
TicksPerSecond specifies the frequency of the ticker. Default is 1e9.
Functions ¶
func MuSecondsToTicks ¶
MuSecondsToTicks converts a fractional number of micro-seconds into a whole number of ticks.
func SecondsToTicks ¶
SecondsToTicks converts a fractional number of seconds into a whole number of ticks.
func SetTicksPerSecond ¶
SetTicksPerSecond changes the value of TicksPerSecond (the frequency of the ticker) and the associated values [FloatTicksPersecond] and TickValue. the frequency of the ticker. The default value is 1e7.
func TicksToSeconds ¶
TicksToSeconds converts a whole number of ticks into a fractional number of seconds.
func TimeToSeconds ¶
TimeToSeconds converts a Time value into a fractional number of seconds. The Priority field is ignored.
Types ¶
type Time ¶
Time measures the number of ticks since the epoch (in TickCnt). The tick count provides a natural ordering of time values -- smaller numbers happen earlier than larger numbers. In order to provide determinism, the order in which simultaneous events occur is specified by Priority -- among simultaneous events, smaller numbers for Priority occur before larger numbers.
func InfinityTime ¶
func InfinityTime() Time
InfinityTime marks the end of time. Every other time in a running simulation is less than InfinityTime
func SecondsToTime ¶
SecondsToTime converts a fractional number of seconds into an equivalent Time value. The returned Priority is 0.
func SecondsToTimePri ¶ added in v0.1.5
SecondsToTime converts a fractional number of seconds into an equivalent Time value. The returned Priority is 0.
func (Time) EQ ¶
EQ returns true iff the receiver Time is equal to the argument Time. Both ticks and priority have to be the same for true to be returned
func (Time) GE ¶
GE returns true iff the receiver Time is greater than or equal to the argument Time.
func (Time) NEQ ¶
NEQ returns true iff the receiver time is not equal to the argument Time. Like all of the Time comparison functions, both the Ticks and the Priority are used.
func (*Time) Pri ¶
Pri returns the priority of an event, which plays a role in ordering when two events have the same primary key value. Events with lower priority number are ordered to appear before events with higher priority numbers
func (Time) Seconds ¶
Ticks returns the float64 respresentation of the primary key of a Time data structure, usually used to describe a length of time (e.g. between events)
func (*Time) SecondsStr ¶
SecondsStr returns a human-readble representation of a Time. The time is represented as fractional seconds rather than ticks.
func (*Time) SetTicks ¶
SetTicks sets the time associated with an event. N.b.: this does not modify the Priority.