Skip to content

Commit 048d183

Browse files
authored
Merge pull request #709 from cquiroz/perf-api
Performance api improvements
2 parents f0c4f15 + b2d400b commit 048d183

File tree

4 files changed

+67
-24
lines changed

4 files changed

+67
-24
lines changed

api-reports/2_12.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16778,30 +16778,33 @@ Pbkdf2Params[SO] val salt = salt0
1677816778
Performance[JC] def clearMarks(markName: String?): Unit
1677916779
Performance[JC] def clearMeasures(measureName: String?): Unit
1678016780
Performance[JC] def clearResourceTimings(): Unit
16781-
Performance[JC] def getEntries(): js.Dynamic
16782-
Performance[JC] def getEntriesByName(name: String, entryType: String?): js.Dynamic
16783-
Performance[JC] def getEntriesByType(entryType: String): js.Dynamic
16784-
Performance[JC] def getMarks(markName: String?): js.Dynamic
16785-
Performance[JC] def getMeasures(measureName: String?): js.Dynamic
16786-
Performance[JC] def mark(markName: String): Unit
16787-
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): Unit
16781+
Performance[JC] def getEntries(): js.Array[PerformanceEntry]
16782+
Performance[JC] def getEntriesByName(name: String, `type`: String?): js.Array[PerformanceEntry]
16783+
Performance[JC] def getEntriesByType(entryType: String): js.Array[PerformanceEntry]
16784+
Performance[JC] def getMarks(markName: String?): js.Dynamic (@deprecated in 2.8.0)
16785+
Performance[JC] def getMeasures(measureName: String?): js.Dynamic (@deprecated in 2.8.0)
16786+
Performance[JC] def mark(markName: String): PerformanceMark
16787+
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): PerformanceMeasure
1678816788
Performance[JC] def navigation: PerformanceNavigation
1678916789
Performance[JC] def now(): Double
1679016790
Performance[JC] def setResourceTimingBufferSize(maxSize: Int): Unit
1679116791
Performance[JC] def timing: PerformanceTiming
16792-
Performance[JC] def toJSON(): js.Dynamic
16792+
Performance[JC] def toJSON(): js.Object
1679316793
PerformanceEntry[JC] def duration: Int
1679416794
PerformanceEntry[JC] def entryType: String
1679516795
PerformanceEntry[JC] def name: String
1679616796
PerformanceEntry[JC] def startTime: Double
16797+
PerformanceEntry[JC] def toJSON(): js.Object
1679716798
PerformanceMark[JC] def duration: Int
1679816799
PerformanceMark[JC] def entryType: String
1679916800
PerformanceMark[JC] def name: String
1680016801
PerformanceMark[JC] def startTime: Double
16802+
PerformanceMark[JC] def toJSON(): js.Object
1680116803
PerformanceMeasure[JC] def duration: Int
1680216804
PerformanceMeasure[JC] def entryType: String
1680316805
PerformanceMeasure[JC] def name: String
1680416806
PerformanceMeasure[JC] def startTime: Double
16807+
PerformanceMeasure[JC] def toJSON(): js.Object
1680516808
PerformanceNavigation[JC] def redirectCount: Int
1680616809
PerformanceNavigation[JC] def toJSON(): js.Dynamic
1680716810
PerformanceNavigation[JC] def `type`: Int
@@ -16824,6 +16827,7 @@ PerformanceResourceTiming[JC] def requestStart: Int
1682416827
PerformanceResourceTiming[JC] var responseEnd: Int
1682516828
PerformanceResourceTiming[JC] def responseStart: Int
1682616829
PerformanceResourceTiming[JC] def startTime: Double
16830+
PerformanceResourceTiming[JC] def toJSON(): js.Object
1682716831
PerformanceTiming[JC] def connectEnd: Double
1682816832
PerformanceTiming[JC] def connectStart: Double
1682916833
PerformanceTiming[JC] def domComplete: Double

api-reports/2_13.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16778,30 +16778,33 @@ Pbkdf2Params[SO] val salt = salt0
1677816778
Performance[JC] def clearMarks(markName: String?): Unit
1677916779
Performance[JC] def clearMeasures(measureName: String?): Unit
1678016780
Performance[JC] def clearResourceTimings(): Unit
16781-
Performance[JC] def getEntries(): js.Dynamic
16782-
Performance[JC] def getEntriesByName(name: String, entryType: String?): js.Dynamic
16783-
Performance[JC] def getEntriesByType(entryType: String): js.Dynamic
16784-
Performance[JC] def getMarks(markName: String?): js.Dynamic
16785-
Performance[JC] def getMeasures(measureName: String?): js.Dynamic
16786-
Performance[JC] def mark(markName: String): Unit
16787-
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): Unit
16781+
Performance[JC] def getEntries(): js.Array[PerformanceEntry]
16782+
Performance[JC] def getEntriesByName(name: String, `type`: String?): js.Array[PerformanceEntry]
16783+
Performance[JC] def getEntriesByType(entryType: String): js.Array[PerformanceEntry]
16784+
Performance[JC] def getMarks(markName: String?): js.Dynamic (@deprecated in 2.8.0)
16785+
Performance[JC] def getMeasures(measureName: String?): js.Dynamic (@deprecated in 2.8.0)
16786+
Performance[JC] def mark(markName: String): PerformanceMark
16787+
Performance[JC] def measure(measureName: String, startMarkName: String?, endMarkName: String?): PerformanceMeasure
1678816788
Performance[JC] def navigation: PerformanceNavigation
1678916789
Performance[JC] def now(): Double
1679016790
Performance[JC] def setResourceTimingBufferSize(maxSize: Int): Unit
1679116791
Performance[JC] def timing: PerformanceTiming
16792-
Performance[JC] def toJSON(): js.Dynamic
16792+
Performance[JC] def toJSON(): js.Object
1679316793
PerformanceEntry[JC] def duration: Int
1679416794
PerformanceEntry[JC] def entryType: String
1679516795
PerformanceEntry[JC] def name: String
1679616796
PerformanceEntry[JC] def startTime: Double
16797+
PerformanceEntry[JC] def toJSON(): js.Object
1679716798
PerformanceMark[JC] def duration: Int
1679816799
PerformanceMark[JC] def entryType: String
1679916800
PerformanceMark[JC] def name: String
1680016801
PerformanceMark[JC] def startTime: Double
16802+
PerformanceMark[JC] def toJSON(): js.Object
1680116803
PerformanceMeasure[JC] def duration: Int
1680216804
PerformanceMeasure[JC] def entryType: String
1680316805
PerformanceMeasure[JC] def name: String
1680416806
PerformanceMeasure[JC] def startTime: Double
16807+
PerformanceMeasure[JC] def toJSON(): js.Object
1680516808
PerformanceNavigation[JC] def redirectCount: Int
1680616809
PerformanceNavigation[JC] def toJSON(): js.Dynamic
1680716810
PerformanceNavigation[JC] def `type`: Int
@@ -16824,6 +16827,7 @@ PerformanceResourceTiming[JC] def requestStart: Int
1682416827
PerformanceResourceTiming[JC] var responseEnd: Int
1682516828
PerformanceResourceTiming[JC] def responseStart: Int
1682616829
PerformanceResourceTiming[JC] def startTime: Double
16830+
PerformanceResourceTiming[JC] def toJSON(): js.Object
1682716831
PerformanceTiming[JC] def connectEnd: Double
1682816832
PerformanceTiming[JC] def connectStart: Double
1682916833
PerformanceTiming[JC] def domComplete: Double

dom/src/main/scala/org/scalajs/dom/Performance.scala

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import scala.scalajs.js.annotation._
1515
*/
1616
@js.native
1717
@JSGlobal
18-
class Performance extends js.Object {
18+
class Performance private[this] () extends js.Object {
1919

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

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

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

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

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

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

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

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

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

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

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

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

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

5676
/** Returns a DOMHighResTimeStamp representing the amount of milliseconds elapsed since the start of the navigation,

dom/src/main/scala/org/scalajs/dom/PerformanceEntry.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ package org.scalajs.dom
99
import scala.scalajs.js
1010
import scala.scalajs.js.annotation._
1111

12+
/** Encapsulates a single performance metric that is part of the browser's performance timeline. */
1213
@js.native
1314
@JSGlobal
1415
class PerformanceEntry extends js.Object {
16+
17+
/** The name for a performance entry. It acts as an identifier, but it does not have to be unique. The value depends
18+
* on the subclass.
19+
*/
1520
def name: String = js.native
1621

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

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

32+
/** The type of performance metric that this entry represents. */
2133
def entryType: String = js.native
34+
35+
/** Returns a JSON representation of the [[PerformanceEntry]] object. */
36+
def toJSON(): js.Object = js.native
2237
}

0 commit comments

Comments
 (0)