record static method
Record a trace event to the buffer.
Implementation
@pragma('vm:prefer-inline')
static void record(
int stringId,
int phase,
TraceCategory category, {
Map<String, String>? metadata,
}) {
if (!activeCategories.contains(category)) return;
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;
if (metadata != null) {
_activeMetadata[idx ~/ 2] = metadata;
}
final nextIdx = (idx + 2) & _bufferMask;
_writeIndex = nextIdx;
if (nextIdx == 0) {
_swapAndFlush();
}
}