@@ -12,14 +12,19 @@ export function createDeveloperModeContainer() {
12
12
13
13
const content = document . createElement ( "div" ) ;
14
14
content . className = "developer-mode-content" ;
15
+
15
16
content . append ( createUIForSuites ( ) ) ;
16
17
18
+ const settings = document . createElement ( "div" ) ;
19
+ settings . className = "settings" ;
20
+ settings . append ( createUIForIterationCount ( ) ) ;
21
+ settings . append ( createUIForMeasurementMethod ( ) ) ;
22
+ settings . append ( createUIForWarmupSuite ( ) ) ;
23
+ settings . append ( createUIForWarmupBeforeSync ( ) ) ;
24
+ settings . append ( createUIForSyncStepDelay ( ) ) ;
25
+
17
26
content . append ( document . createElement ( "hr" ) ) ;
18
- content . append ( createUIForMeasurementMethod ( ) ) ;
19
- content . append ( document . createElement ( "br" ) ) ;
20
- content . append ( createUIForWarmupSuite ( ) ) ;
21
- content . append ( document . createElement ( "br" ) ) ;
22
- content . append ( createUIForIterationCount ( ) ) ;
27
+ content . append ( settings ) ;
23
28
24
29
content . append ( document . createElement ( "hr" ) ) ;
25
30
content . append ( createUIForRun ( ) ) ;
@@ -29,7 +34,13 @@ export function createDeveloperModeContainer() {
29
34
return container ;
30
35
}
31
36
32
- export function createUIForMeasurementMethod ( ) {
37
+ function span ( text ) {
38
+ const span = document . createElement ( "span" ) ;
39
+ span . textContent = text ;
40
+ return span ;
41
+ }
42
+
43
+ function createUIForMeasurementMethod ( ) {
33
44
let check = document . createElement ( "input" ) ;
34
45
check . type = "checkbox" ;
35
46
check . id = "measurement-method" ;
@@ -41,12 +52,12 @@ export function createUIForMeasurementMethod() {
41
52
} ;
42
53
43
54
let label = document . createElement ( "label" ) ;
44
- label . append ( check , " " , "rAF timing" ) ;
55
+ label . append ( check , " " , span ( "rAF timing" ) ) ;
45
56
46
57
return label ;
47
58
}
48
59
49
- export function createUIForWarmupSuite ( ) {
60
+ function createUIForWarmupSuite ( ) {
50
61
let check = document . createElement ( "input" ) ;
51
62
check . type = "checkbox" ;
52
63
check . id = "warmup-suite" ;
@@ -58,38 +69,65 @@ export function createUIForWarmupSuite() {
58
69
} ;
59
70
60
71
let label = document . createElement ( "label" ) ;
61
- label . append ( check , " " , "warmup suite" ) ;
72
+ label . append ( check , " " , span ( "Use Warmup Suite" ) ) ;
62
73
63
74
return label ;
64
75
}
65
76
66
- export function createUIForIterationCount ( ) {
67
- let range = document . createElement ( "input" ) ;
68
- range . type = "range" ;
69
- range . id = "iteration-count" ;
70
- range . min = 1 ;
71
- range . max = 20 ;
72
- range . value = params . iterationCount ;
73
-
74
- let label = document . createElement ( "label" ) ;
75
- let countLabel = document . createElement ( "span" ) ;
76
- countLabel . textContent = params . iterationCount ;
77
- label . append ( "iterations: " , countLabel , document . createElement ( "br" ) , range ) ;
78
-
79
- range . oninput = ( ) => {
80
- countLabel . textContent = range . value ;
77
+ function createUIForIterationCount ( ) {
78
+ const { range, label } = createTimeRangeUI ( "Iterations: " , params . iterationCount , "#" , 1 , 200 ) ;
79
+ range . onchange = ( ) => {
80
+ params . iterationCount = parseInt ( range . value ) ;
81
+ updateURL ( ) ;
81
82
} ;
83
+ return label ;
84
+ }
82
85
86
+ function createUIForWarmupBeforeSync ( ) {
87
+ const { range, label } = createTimeRangeUI ( "Warmup time: " , params . warmupBeforeSync ) ;
83
88
range . onchange = ( ) => {
84
- params . iterationCount = parseInt ( range . value ) ;
89
+ params . warmupBeforeSync = parseInt ( range . value ) ;
85
90
updateURL ( ) ;
86
91
} ;
92
+ return label ;
93
+ }
87
94
95
+ function createUIForSyncStepDelay ( ) {
96
+ const { range, label } = createTimeRangeUI ( "Sync step delay: " , params . waitBeforeSync ) ;
97
+ range . onchange = ( ) => {
98
+ params . waitBeforeSync = parseInt ( range . value ) ;
99
+ updateURL ( ) ;
100
+ } ;
88
101
return label ;
89
102
}
90
103
91
- export function createUIForSuites ( ) {
104
+ function createTimeRangeUI ( labelText , initialValue , unit = "ms" , min = 0 , max = 1000 ) {
105
+ const range = document . createElement ( "input" ) ;
106
+ range . type = "range" ;
107
+ range . min = min ;
108
+ range . max = max ;
109
+ range . value = initialValue ;
110
+
111
+ const rangeValueAndUnit = document . createElement ( "span" ) ;
112
+ rangeValueAndUnit . className = "range-label-data" ;
113
+
114
+ const rangeValue = document . createElement ( "span" ) ;
115
+ rangeValue . textContent = initialValue ;
116
+ rangeValueAndUnit . append ( rangeValue , " " , unit ) ;
117
+
118
+ const label = document . createElement ( "label" ) ;
119
+ label . append ( span ( labelText ) , range , rangeValueAndUnit ) ;
120
+
121
+ range . oninput = ( ) => {
122
+ rangeValue . textContent = range . value ;
123
+ } ;
124
+
125
+ return { range, label } ;
126
+ }
127
+
128
+ function createUIForSuites ( ) {
92
129
const control = document . createElement ( "nav" ) ;
130
+ control . className = "suites" ;
93
131
const ol = document . createElement ( "ol" ) ;
94
132
const checkboxes = [ ] ;
95
133
const setSuiteEnabled = ( suiteIndex , enabled ) => {
@@ -235,15 +273,13 @@ function updateURL() {
235
273
else
236
274
url . searchParams . delete ( "measurementMethod" ) ;
237
275
238
- if ( params . iterationCount !== defaultParams . iterationCount )
239
- url . searchParams . set ( "iterationCount" , params . iterationCount ) ;
240
- else
241
- url . searchParams . delete ( "iterationCount" ) ;
242
-
243
- if ( params . useWarmupSuite !== defaultParams . useWarmupSuite )
244
- url . searchParams . set ( "useWarmupSuite" , params . useWarmupSuite ) ;
245
- else
246
- url . searchParams . delete ( "useWarmupSuite" ) ;
276
+ const boolParamKeys = [ "iterationCount" , "useWarmupSuite" , "warmupBeforeSync" , "waitBeforeSync" ] ;
277
+ for ( const paramKey of boolParamKeys ) {
278
+ if ( params [ paramKey ] !== defaultParams [ paramKey ] )
279
+ url . searchParams . set ( paramKey , params [ paramKey ] ) ;
280
+ else
281
+ url . searchParams . delete ( paramKey ) ;
282
+ }
247
283
248
284
// Only push state if changed
249
285
url . search = decodeURIComponent ( url . search ) ;
0 commit comments