@@ -227,74 +227,6 @@ describe('css splitter', () => {
227227 }
228228 expect ( splitCssText ( cssText , style ) ) . toEqual ( sections ) ;
229229 } ) ;
230-
231- it (
232- 'the second time is faster' ,
233- {
234- // because we're timing every so often this might flap because computers
235- retry : 3 ,
236- } ,
237- ( ) => {
238- const cssText = fs . readFileSync (
239- path . resolve ( __dirname , './css/benchmark.css' ) ,
240- 'utf8' ,
241- ) ;
242-
243- const parts = cssText . split ( '}' ) ;
244- const sections = [ ] ;
245- for ( let i = 0 ; i < parts . length - 1 ; i ++ ) {
246- if ( i % 100 === 0 ) {
247- sections . push ( parts [ i ] + '}' ) ;
248- } else {
249- sections [ sections . length - 1 ] += parts [ i ] + '}' ;
250- }
251- }
252- sections [ sections . length - 1 ] += parts [ parts . length - 1 ] ;
253-
254- expect ( cssText . length ) . toEqual ( sections . join ( '' ) . length ) ;
255-
256- const style = JSDOM . fragment ( `<style></style>` ) . querySelector ( 'style' ) ;
257- if ( style ) {
258- sections . forEach ( ( section ) => {
259- style . appendChild ( JSDOM . fragment ( section ) ) ;
260- } ) ;
261- }
262-
263- // Measure the time for the first execution
264- const startFirst = performance . now ( ) ;
265- const firstResult = splitCssText ( cssText , style ) ;
266- const endFirst = performance . now ( ) ;
267- const firstExecutionTime = endFirst - startFirst ;
268-
269- expect ( firstResult ) . toEqual ( sections ) ;
270-
271- const cachedExecutionTimes = [ ] ;
272- for ( let i = 0 ; i < 100 ; i ++ ) {
273- // Measure the time for the second execution
274- const startSecond = performance . now ( ) ;
275- const secondResult = splitCssText ( cssText , style ) ;
276- const endSecond = performance . now ( ) ;
277-
278- expect ( secondResult ) . toEqual ( firstResult ) ;
279- const secondExecutionTime = endSecond - startSecond ;
280- cachedExecutionTimes . push ( secondExecutionTime ) ;
281- }
282-
283- // Assert that the second execution is faster
284- expect (
285- cachedExecutionTimes . every ( ( time ) => time < firstExecutionTime ) ,
286- ) . toBe ( true ) ;
287-
288- // Optional: Log the execution times for debugging
289- console . log ( `First execution time: ${ firstExecutionTime } ms` ) ;
290- console . log (
291- `Average execution time for the second execution: ${
292- cachedExecutionTimes . reduce ( ( a , b ) => a + b ) /
293- cachedExecutionTimes . length
294- } ms`,
295- ) ;
296- } ,
297- ) ;
298230} ) ;
299231
300232describe ( 'applyCssSplits css rejoiner' , function ( ) {
0 commit comments