record static method

void record(
  1. int stringId,
  2. int phase
)

Record a trace event to the buffer.

Implementation

@pragma('vm:prefer-inline')
static void record(int stringId, int phase) {
  if (!isEnabled) return;
  final idx = _writeIndex;

  // Word 0: (stringId << 32) | (isolateId << 8) | phase
  _activeBuffer[idx] = (stringId << 32) | (_isolateId << 8) | phase;

  // Word 1: monotonic timestamp
  _activeBuffer[idx + 1] = _stopwatch.elapsedMicroseconds;

  final nextIdx = (idx + 2) & _bufferMask;
  _writeIndex = nextIdx;

  if (nextIdx == 0) {
    _swapAndFlush();
  }
}