MCPcopy
hub / github.com/grafana/k6 / NewExecutionSegmentSequenceFromString

Function NewExecutionSegmentSequenceFromString

lib/execution_segment.go:324–355  ·  view source on GitHub ↗

NewExecutionSegmentSequenceFromString parses strings of the format "r1,r2,r3,...,rn", which represents the sequences like (r1, r2], (r2, r3], (r3, r4], ..., (r{n-1}, rn].

(strSeq string)

Source from the content-addressed store, hash-verified

322// "r1,r2,r3,...,rn", which represents the sequences like (r1, r2], (r2, r3],
323// (r3, r4], ..., (r{n-1}, rn].
324func NewExecutionSegmentSequenceFromString(strSeq string) (ExecutionSegmentSequence, error) {
325 if len(strSeq) == 0 {
326 return nil, nil
327 }
328
329 points := strings.Split(strSeq, ",")
330 if len(points) < 2 {
331 return nil, fmt.Errorf("at least 2 points are needed for an execution segment sequence, %d given", len(points))
332 }
333 var start *big.Rat
334
335 segments := make([]*ExecutionSegment, 0, len(points)-1)
336 for i, point := range points {
337 rat, err := stringToRat(point)
338 if err != nil {
339 return nil, err
340 }
341 if i == 0 {
342 start = rat
343 continue
344 }
345
346 segment, err := NewExecutionSegment(start, rat)
347 if err != nil {
348 return nil, err
349 }
350 segments = append(segments, segment)
351 start = rat
352 }
353
354 return NewExecutionSegmentSequence(segments...)
355}
356
357// UnmarshalText implements the encoding.TextUnmarshaler interface, so that
358// execution segment sequences can be specified as CLI flags, environment

Callers 14

setupExecutorTestFunction · 0.92
TestExecutionStateVUIDsFunction · 0.92
TestOptionsTestFullFunction · 0.92
UnmarshalTextMethod · 0.85
TestExecutionTupleScaleFunction · 0.85
TestBigScaleFunction · 0.85
TestGetStripedOffsetsFunction · 0.85
TestSequenceLCDFunction · 0.85

Calls 5

stringToRatFunction · 0.85
NewExecutionSegmentFunction · 0.85
SplitMethod · 0.80
ErrorfMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…