MCPcopy Create free account
hub / github.com/facebook/time / BestSample

Method BestSample

phc/offset.go:92–102  ·  view source on GitHub ↗

BestSample finds a sample which took the least time to be read; the logic is loosely based on sysoff_estimate from ptp4l sysoff.c

()

Source from the content-addressed store, hash-verified

90// BestSample finds a sample which took the least time to be read;
91// the logic is loosely based on sysoff_estimate from ptp4l sysoff.c
92func (extended *PTPSysOffsetExtended) BestSample() SysoffResult {
93 best := sysoffFromExtendedTS(extended.Ts[0])
94 for i := 1; i < int(extended.Samples); i++ {
95 sysoff := sysoffFromExtendedTS(extended.Ts[i])
96 if sysoff.Delay < best.Delay {
97 best = sysoff
98 }
99 }
100 best.SysClockID = int(extended.ClockID)
101 return best
102}
103
104// TimeAndOffsetFromDevice returns time we got from phc device + offset
105func TimeAndOffsetFromDevice(device string, method TimeMethod) (SysoffResult, error) {

Callers 5

TestSysoffBestSampleFunction · 0.95
TimeAndOffsetFromDeviceFunction · 0.80
phcdiffRunFunction · 0.80
phc2phcRunFunction · 0.80
NewFunction · 0.80

Calls 1

sysoffFromExtendedTSFunction · 0.85

Tested by 1

TestSysoffBestSampleFunction · 0.76