MCPcopy Index your code
hub / github.com/nodejs/node / bufferUserTiming

Function bufferUserTiming

lib/internal/perf/observe.js:399–428  ·  view source on GitHub ↗

* Add the user timing entry to the global buffer.

(entry)

Source from the content-addressed store, hash-verified

397 * Add the user timing entry to the global buffer.
398 */
399function bufferUserTiming(entry) {
400 const entryType = entry.entryType;
401 let buffer;
402 if (entryType === 'mark') {
403 buffer = markEntryBuffer;
404 } else if (entryType === 'measure') {
405 buffer = measureEntryBuffer;
406 } else {
407 return;
408 }
409
410 ArrayPrototypePush(buffer, entry);
411 const count = buffer.length;
412
413 if (count > kPerformanceEntryBufferWarnSize &&
414 !kWarnedEntryTypes.has(entryType)) {
415 kWarnedEntryTypes.set(entryType, true);
416 // No error code for this since it is a Warning
417 // eslint-disable-next-line no-restricted-syntax
418 const w = new Error('Possible perf_hooks memory leak detected. ' +
419 `${count} ${entryType} entries added to the global ` +
420 'performance entry buffer. Use ' +
421 `${kClearPerformanceEntryBuffers[entryType]} to ` +
422 'clear the buffer.');
423 w.name = 'MaxPerformanceEntryBufferExceededWarning';
424 w.entryType = entryType;
425 w.count = count;
426 process.emitWarning(w);
427 }
428}
429
430/**
431 * Add the resource timing entry to the global buffer if the buffer size is not

Callers 2

markFunction · 0.85
measureFunction · 0.85

Calls 2

hasMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected