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

Function prepareMathParameters

fbclock/daemon/math.go:222–263  ·  view source on GitHub ↗
(lastN []*DataPoint)

Source from the content-addressed store, hash-verified

220}
221
222func prepareMathParameters(lastN []*DataPoint) map[string][]float64 {
223 size := len(lastN)
224 if size == 0 {
225 // Defensive: no live path calls this with an empty slice (calcW runs after pushDataPoint;
226 // calcDriftPPB runs after its gate). The guard prevents a latent negative-length make below
227 // and a lastN[0] panic.
228 return map[string][]float64{
229 "offset": {},
230 "delay": {},
231 "freq": {},
232 "clockaccuracy": {},
233 "freqchange": {},
234 "freqchangeabs": {},
235 }
236 }
237 offsets := make([]float64, size)
238 delays := make([]float64, size)
239 freqs := make([]float64, size)
240 clockAccuracies := make([]float64, size)
241 freqChanges := make([]float64, size-1)
242 freqChangesAbs := make([]float64, size-1)
243 prev := lastN[0]
244 for i := range size {
245 offsets[i] = lastN[i].MasterOffsetNS
246 delays[i] = lastN[i].PathDelayNS
247 freqs[i] = lastN[i].FreqAdjustmentPPB
248 clockAccuracies[i] = lastN[i].ClockAccuracyNS
249 if i != 0 {
250 freqChanges[i-1] = lastN[i].FreqAdjustmentPPB - prev.FreqAdjustmentPPB
251 freqChangesAbs[i-1] = math.Abs(lastN[i].FreqAdjustmentPPB - prev.FreqAdjustmentPPB)
252 }
253 prev = lastN[i]
254 }
255 return map[string][]float64{
256 "offset": offsets,
257 "delay": delays,
258 "freq": freqs,
259 "clockaccuracy": clockAccuracies,
260 "freqchange": freqChanges,
261 "freqchangeabs": freqChangesAbs,
262 }
263}
264
265func mapOfInterface(m map[string][]float64) map[string]any {
266 mm := make(map[string]any, len(m))

Callers 4

calcWMethod · 0.85
calcDriftPPBMethod · 0.85

Calls

no outgoing calls

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…