Skip to content

Commit

Permalink
Merge pull request #709 from cquiroz/perf-api
Browse files Browse the repository at this point in the history
Performance api improvements
  • Loading branch information
armanbilge authored Sep 27, 2023
2 parents f0c4f15 + b2d400b commit 048d183
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 24 deletions.
20 changes: 12 additions & 8 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16778,30 +16778,33 @@ Pbkdf2Params[SO] val salt = salt0
Performance[JC] def clearMarks(markName: String?): Unit
Performance[JC] def clearMeasures(measureName: String?): Unit
Performance[JC] def clearResourceTimings(): Unit
Performance[JC] def getEntries(): js.Dynamic
Performance[JC] def getEntriesByName(name: String, entryType: String?): js.Dynamic
Performance[JC] def getEntriesByType(entryType: String): js.Dynamic
Performance[JC] def getMarks(markName: String?): js.Dynamic
Performance[JC] def getMeasures(measureName: String?): js.Dynamic
Performance[JC] def mark(markName: String): Unit
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): Unit
Performance[JC] def getEntries(): js.Array[PerformanceEntry]
Performance[JC] def getEntriesByName(name: String, `type`: String?): js.Array[PerformanceEntry]
Performance[JC] def getEntriesByType(entryType: String): js.Array[PerformanceEntry]
Performance[JC] def getMarks(markName: String?): js.Dynamic (@deprecated in 2.8.0)
Performance[JC] def getMeasures(measureName: String?): js.Dynamic (@deprecated in 2.8.0)
Performance[JC] def mark(markName: String): PerformanceMark
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): PerformanceMeasure
Performance[JC] def navigation: PerformanceNavigation
Performance[JC] def now(): Double
Performance[JC] def setResourceTimingBufferSize(maxSize: Int): Unit
Performance[JC] def timing: PerformanceTiming
Performance[JC] def toJSON(): js.Dynamic
Performance[JC] def toJSON(): js.Object
PerformanceEntry[JC] def duration: Int
PerformanceEntry[JC] def entryType: String
PerformanceEntry[JC] def name: String
PerformanceEntry[JC] def startTime: Double
PerformanceEntry[JC] def toJSON(): js.Object
PerformanceMark[JC] def duration: Int
PerformanceMark[JC] def entryType: String
PerformanceMark[JC] def name: String
PerformanceMark[JC] def startTime: Double
PerformanceMark[JC] def toJSON(): js.Object
PerformanceMeasure[JC] def duration: Int
PerformanceMeasure[JC] def entryType: String
PerformanceMeasure[JC] def name: String
PerformanceMeasure[JC] def startTime: Double
PerformanceMeasure[JC] def toJSON(): js.Object
PerformanceNavigation[JC] def redirectCount: Int
PerformanceNavigation[JC] def toJSON(): js.Dynamic
PerformanceNavigation[JC] def `type`: Int
Expand All @@ -16824,6 +16827,7 @@ PerformanceResourceTiming[JC] def requestStart: Int
PerformanceResourceTiming[JC] var responseEnd: Int
PerformanceResourceTiming[JC] def responseStart: Int
PerformanceResourceTiming[JC] def startTime: Double
PerformanceResourceTiming[JC] def toJSON(): js.Object
PerformanceTiming[JC] def connectEnd: Double
PerformanceTiming[JC] def connectStart: Double
PerformanceTiming[JC] def domComplete: Double
Expand Down
20 changes: 12 additions & 8 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16778,30 +16778,33 @@ Pbkdf2Params[SO] val salt = salt0
Performance[JC] def clearMarks(markName: String?): Unit
Performance[JC] def clearMeasures(measureName: String?): Unit
Performance[JC] def clearResourceTimings(): Unit
Performance[JC] def getEntries(): js.Dynamic
Performance[JC] def getEntriesByName(name: String, entryType: String?): js.Dynamic
Performance[JC] def getEntriesByType(entryType: String): js.Dynamic
Performance[JC] def getMarks(markName: String?): js.Dynamic
Performance[JC] def getMeasures(measureName: String?): js.Dynamic
Performance[JC] def mark(markName: String): Unit
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): Unit
Performance[JC] def getEntries(): js.Array[PerformanceEntry]
Performance[JC] def getEntriesByName(name: String, `type`: String?): js.Array[PerformanceEntry]
Performance[JC] def getEntriesByType(entryType: String): js.Array[PerformanceEntry]
Performance[JC] def getMarks(markName: String?): js.Dynamic (@deprecated in 2.8.0)
Performance[JC] def getMeasures(measureName: String?): js.Dynamic (@deprecated in 2.8.0)
Performance[JC] def mark(markName: String): PerformanceMark
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): PerformanceMeasure
Performance[JC] def navigation: PerformanceNavigation
Performance[JC] def now(): Double
Performance[JC] def setResourceTimingBufferSize(maxSize: Int): Unit
Performance[JC] def timing: PerformanceTiming
Performance[JC] def toJSON(): js.Dynamic
Performance[JC] def toJSON(): js.Object
PerformanceEntry[JC] def duration: Int
PerformanceEntry[JC] def entryType: String
PerformanceEntry[JC] def name: String
PerformanceEntry[JC] def startTime: Double
PerformanceEntry[JC] def toJSON(): js.Object
PerformanceMark[JC] def duration: Int
PerformanceMark[JC] def entryType: String
PerformanceMark[JC] def name: String
PerformanceMark[JC] def startTime: Double
PerformanceMark[JC] def toJSON(): js.Object
PerformanceMeasure[JC] def duration: Int
PerformanceMeasure[JC] def entryType: String
PerformanceMeasure[JC] def name: String
PerformanceMeasure[JC] def startTime: Double
PerformanceMeasure[JC] def toJSON(): js.Object
PerformanceNavigation[JC] def redirectCount: Int
PerformanceNavigation[JC] def toJSON(): js.Dynamic
PerformanceNavigation[JC] def `type`: Int
Expand All @@ -16824,6 +16827,7 @@ PerformanceResourceTiming[JC] def requestStart: Int
PerformanceResourceTiming[JC] var responseEnd: Int
PerformanceResourceTiming[JC] def responseStart: Int
PerformanceResourceTiming[JC] def startTime: Double
PerformanceResourceTiming[JC] def toJSON(): js.Object
PerformanceTiming[JC] def connectEnd: Double
PerformanceTiming[JC] def connectStart: Double
PerformanceTiming[JC] def domComplete: Double
Expand Down
36 changes: 28 additions & 8 deletions dom/src/main/scala/org/scalajs/dom/Performance.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.scalajs.js.annotation._
*/
@js.native
@JSGlobal
class Performance extends js.Object {
class Performance private[this] () extends js.Object {

/** The Performance.navigation read-only property returns a PerformanceNavigation object representing the type of
* navigation that occurs in the given browsing context, like the amount of redirections needed to fetch the
Expand All @@ -28,29 +28,49 @@ class Performance extends js.Object {
*/
def timing: PerformanceTiming = js.native

def getEntriesByType(entryType: String): js.Dynamic = js.native
/** Returns an array of [[PerformanceEntry]] objects currently present in the performance timeline for a given type */
def getEntriesByType(entryType: String): js.Array[PerformanceEntry] = js.native

/** Is a jsonizer returning a json object representing the Performance object. */
def toJSON(): js.Dynamic = js.native
/** Returns a JSON representation of the [[Performance]] object. */
def toJSON(): js.Object = js.native

@deprecated("No such API in the spec", "2.8.0")
def getMeasures(measureName: String = js.native): js.Dynamic = js.native

/** Removes all or specific [[PerformanceMark]] objects from the browser's performance timeline. */
def clearMarks(markName: String = js.native): Unit = js.native

@deprecated("No such API in the spec", "2.8.0")
def getMarks(markName: String = js.native): js.Dynamic = js.native

/** Removes all performance entries with an `entryType` of "resource" from the browser's performance timeline and sets
* the size of the performance resource data buffer to zero.
*/
def clearResourceTimings(): Unit = js.native

def mark(markName: String): Unit = js.native
/** Creates a named [[PerformanceMark]] object representing a high resolution timestamp marker in the browser's
* performance timeline.
*/
def mark(markName: String): PerformanceMark = js.native

def measure(measureName: String, startMarkName: String = js.native, endMarkName: String = js.native): Unit = js.native
/** Creates a named [[PerformanceMeasure]] object representing a time measurement between two marks in the browser's
* performance timeline.
*/
def measure(measureName: String, startMarkName: String = js.native,
endMarkName: String = js.native): PerformanceMeasure = js.native

def getEntriesByName(name: String, entryType: String = js.native): js.Dynamic = js.native
/** Returns an array of [[PerformanceEntry]] objects currently present in the performance timeline with the given name
* and type.
*/
def getEntriesByName(name: String, `type`: String = js.native): js.Array[PerformanceEntry] = js.native

def getEntries(): js.Dynamic = js.native
/** All [[PerformanceEntry]] objects currently present in the performance timeline. */
def getEntries(): js.Array[PerformanceEntry] = js.native

/** Removes all or specific [[PerformanceMeasure]] objects from the browser's performance timeline. */
def clearMeasures(measureName: String = js.native): Unit = js.native

/** Sets the desired size of the browser's resource timing buffer which stores the "resource" performance entries. */
def setResourceTimingBufferSize(maxSize: Int): Unit = js.native

/** Returns a DOMHighResTimeStamp representing the amount of milliseconds elapsed since the start of the navigation,
Expand Down
15 changes: 15 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/PerformanceEntry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@ package org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation._

/** Encapsulates a single performance metric that is part of the browser's performance timeline. */
@js.native
@JSGlobal
class PerformanceEntry extends js.Object {

/** The name for a performance entry. It acts as an identifier, but it does not have to be unique. The value depends
* on the subclass.
*/
def name: String = js.native

/** The first timestamp recorded for this performance entry. The meaning of this property depends on the value of this
* entry's [[entryType]].
*/
def startTime: Double = js.native

/** The duration of the performance entry. The meaning of this property depends on the value of this entry's
* [[entryType]].
*/
def duration: Int = js.native

/** The type of performance metric that this entry represents. */
def entryType: String = js.native

/** Returns a JSON representation of the [[PerformanceEntry]] object. */
def toJSON(): js.Object = js.native
}

0 comments on commit 048d183

Please sign in to comment.