--- title: performance.mark() slug: Web/API/Performance/mark tags: - API - Method - Méthode - Reference - Performance web translation_of: Web/API/Performance/mark ---
La méthode mark() crée un {{domxref("DOMHighResTimeStamp", "timestamp")}} dans le tampon d'entrée de performance du navigateur avec le nom donné en argument.
L'horodatage ainsi défini par l'application peut être récupéré par l'une des méthodes getEntries*() de l'interface {{domxref("Performance")}} ({{domxref("Performance.getEntries", "getEntries()")}}, {{domxref("Performance.getEntriesByName", "getEntriesByName()")}} ou {{domxref("Performance.getEntriesByType", "getEntriesByType()")}}).
La méthode mark() stocke ses données en interne sous la forme d'objets {{domxref("PerformanceEntry")}}.
{{AvailableInWorkers}}
performance.mark(name);
nameAucune.
>L'exemple suivant montre comment utiliser mark() pour créer et récupérer des entrées {{domxref("PerformanceMark")}}.
// Crée un ensemble de marqueurs.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");
// Obtient toutes les entrées de PerformanceMark.
const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
// 6
// Obtient toutes les entrées "monkey" de PerformanceMark.
const monkeyEntries = performance.getEntriesByName("monkey");
console.log(monkeyEntries.length);
// 2
// Efface tous les marqueurs.
performance.clearMarks();
| Spécification | Statut | Commentaire |
|---|---|---|
| {{SpecName('User Timing Level 2', '#dom-performance-mark', 'mark()')}} | {{Spec2('User Timing Level 2')}} | Clarification du modèle de traitement mark(). |
| {{SpecName('User Timing', '#dom-performance-mark', 'mark()')}} | {{Spec2('User Timing')}} | Définition initiale. |
{{Compat("api.Performance.mark")}}