* Add the user timing entry to the global buffer.
(entry)
| 397 | * Add the user timing entry to the global buffer. |
| 398 | */ |
| 399 | function 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 |