@@ -100,65 +100,81 @@ describe('formatVnPercent - typical usage scenarios', () => {
100100} )
101101
102102describe ( 'formatVnNumber - realistic batch operations' , ( ) => {
103- bench ( 'format 50 order counts' , ( ) => {
104- for ( let i = 0 ; i < 50 ; i ++ ) {
103+ bench (
104+ 'format 50 order counts' ,
105+ ( ) => {
105106 const count = Math . floor ( Math . random ( ) * 10000 )
106107 formatVnNumber ( count )
107- }
108- } )
108+ } ,
109+ { iterations : 50 } ,
110+ )
109111
110- bench ( 'format 50 product quantities' , ( ) => {
111- for ( let i = 0 ; i < 50 ; i ++ ) {
112+ bench (
113+ 'format 50 product quantities' ,
114+ ( ) => {
112115 const quantity = Math . floor ( Math . random ( ) * 1000 )
113116 formatVnNumber ( quantity )
114- }
115- } )
117+ } ,
118+ { iterations : 50 } ,
119+ )
116120} )
117121
118122describe ( 'formatVnCurrency - realistic batch operations' , ( ) => {
119- bench ( 'format 50 e-commerce prices (10k-50M VND)' , ( ) => {
120- for ( let i = 0 ; i < 50 ; i ++ ) {
123+ bench (
124+ 'format 50 e-commerce prices (10k-50M VND)' ,
125+ ( ) => {
121126 const price = Math . floor ( Math . random ( ) * 49990000 ) + 10000
122127 formatVnCurrency ( price )
123- }
124- } )
128+ } ,
129+ { iterations : 50 } ,
130+ )
125131
126- bench ( 'format 50 invoice totals (100k-100M VND)' , ( ) => {
127- for ( let i = 0 ; i < 50 ; i ++ ) {
132+ bench (
133+ 'format 50 invoice totals (100k-100M VND)' ,
134+ ( ) => {
128135 const total = Math . floor ( Math . random ( ) * 99900000 ) + 100000
129136 formatVnCurrency ( total )
130- }
131- } )
137+ } ,
138+ { iterations : 50 } ,
139+ )
132140
133- bench ( 'format 50 financial amounts (1M-10B VND)' , ( ) => {
134- for ( let i = 0 ; i < 50 ; i ++ ) {
141+ bench (
142+ 'format 50 financial amounts (1M-10B VND)' ,
143+ ( ) => {
135144 const amount = Math . floor ( Math . random ( ) * 9999000000 ) + 1000000
136145 formatVnCurrency ( amount )
137- }
138- } )
146+ } ,
147+ { iterations : 50 } ,
148+ )
139149} )
140150
141151describe ( 'formatVnPercent - realistic batch operations' , ( ) => {
142- bench ( 'format 50 growth rates (-50% to +150%)' , ( ) => {
143- for ( let i = 0 ; i < 50 ; i ++ ) {
152+ bench (
153+ 'format 50 growth rates (-50% to +150%)' ,
154+ ( ) => {
144155 const growth = Math . random ( ) * 2 - 0.5
145156 formatVnPercent ( growth )
146- }
147- } )
157+ } ,
158+ { iterations : 50 } ,
159+ )
148160
149- bench ( 'format 50 conversion rates (0-10%)' , ( ) => {
150- for ( let i = 0 ; i < 50 ; i ++ ) {
161+ bench (
162+ 'format 50 conversion rates (0-10%)' ,
163+ ( ) => {
151164 const rate = Math . random ( ) * 0.1
152165 formatVnPercent ( rate )
153- }
154- } )
166+ } ,
167+ { iterations : 50 } ,
168+ )
155169
156- bench ( 'format 50 completion rates (0-100%)' , ( ) => {
157- for ( let i = 0 ; i < 50 ; i ++ ) {
170+ bench (
171+ 'format 50 completion rates (0-100%)' ,
172+ ( ) => {
158173 const completion = Math . random ( )
159174 formatVnPercent ( completion )
160- }
161- } )
175+ } ,
176+ { iterations : 50 } ,
177+ )
162178} )
163179
164180describe ( 'real-world application scenarios' , ( ) => {
@@ -207,10 +223,11 @@ describe('real-world application scenarios', () => {
207223 formatVnCurrency ( total )
208224 } )
209225
210- bench ( 'display invoice (10 line items)' , ( ) => {
211- let subtotal = 0
226+ bench (
227+ 'display invoice (10 line items)' ,
228+ ( ) => {
229+ let subtotal = 0
212230
213- for ( let i = 0 ; i < 10 ; i ++ ) {
214231 const quantity = Math . floor ( Math . random ( ) * 20 ) + 1
215232 const unitPrice = Math . floor ( Math . random ( ) * 5000000 ) + 50000
216233 const lineTotal = quantity * unitPrice
@@ -219,17 +236,18 @@ describe('real-world application scenarios', () => {
219236 formatVnNumber ( quantity )
220237 formatVnCurrency ( unitPrice )
221238 formatVnCurrency ( lineTotal )
222- }
223239
224- const taxRate = 0.1
225- const taxAmount = subtotal * taxRate
226- const total = subtotal + taxAmount
240+ const taxRate = 0.1
241+ const taxAmount = subtotal * taxRate
242+ const total = subtotal + taxAmount
227243
228- formatVnCurrency ( subtotal )
229- formatVnPercent ( taxRate )
230- formatVnCurrency ( taxAmount )
231- formatVnCurrency ( total )
232- } )
244+ formatVnCurrency ( subtotal )
245+ formatVnPercent ( taxRate )
246+ formatVnCurrency ( taxAmount )
247+ formatVnCurrency ( total )
248+ } ,
249+ { iterations : 10 } ,
250+ )
233251
234252 bench ( 'display financial dashboard (weekly metrics)' , ( ) => {
235253 const weeklyData = Array . from ( { length : 7 } , ( ) => ( {
@@ -257,8 +275,9 @@ describe('real-world application scenarios', () => {
257275 formatVnNumber ( avgOrders )
258276 } )
259277
260- bench ( 'display product catalog (20 products)' , ( ) => {
261- for ( let i = 0 ; i < 20 ; i ++ ) {
278+ bench (
279+ 'display product catalog (20 products)' ,
280+ ( ) => {
262281 const price = Math . floor ( Math . random ( ) * 10000000 ) + 10000
263282 const discount = Math . random ( ) * 0.5
264283 const finalPrice = price * ( 1 - discount )
@@ -272,8 +291,9 @@ describe('real-world application scenarios', () => {
272291 formatVnNumber ( stock )
273292 formatVnNumber ( sold )
274293 formatVnNumber ( rating )
275- }
276- } )
294+ } ,
295+ { iterations : 20 } ,
296+ )
277297
278298 bench ( 'display sales report (monthly performance)' , ( ) => {
279299 const monthlyData = Array . from ( { length : 12 } , ( ) => ( {
@@ -312,8 +332,9 @@ describe('real-world application scenarios', () => {
312332 formatVnCurrency ( total )
313333 } )
314334
315- bench ( 'display data table (50 rows × 6 columns)' , ( ) => {
316- for ( let i = 0 ; i < 50 ; i ++ ) {
335+ bench (
336+ 'display data table (50 rows × 6 columns)' ,
337+ ( ) => {
317338 const orderId = Math . floor ( Math . random ( ) * 100000 )
318339 const quantity = Math . floor ( Math . random ( ) * 100 ) + 1
319340 const unitPrice = Math . floor ( Math . random ( ) * 5000000 ) + 10000
@@ -327,8 +348,9 @@ describe('real-world application scenarios', () => {
327348 formatVnCurrency ( total )
328349 formatVnPercent ( discount )
329350 formatVnPercent ( status )
330- }
331- } )
351+ } ,
352+ { iterations : 50 } ,
353+ )
332354} )
333355
334356describe ( 'input type variations - real-world scenarios' , ( ) => {
@@ -380,15 +402,17 @@ describe('combined operations - real-world scenarios', () => {
380402 formatVnNumber ( orders )
381403 } )
382404
383- bench ( 'format complete product listing (30 products)' , ( ) => {
384- for ( let i = 0 ; i < 30 ; i ++ ) {
405+ bench (
406+ 'format complete product listing (30 products)' ,
407+ ( ) => {
385408 const price = Math . floor ( Math . random ( ) * 10000000 ) + 10000
386409 const discount = Math . random ( ) * 0.5
387410 const stock = Math . floor ( Math . random ( ) * 1000 ) + 1
388411
389412 formatVnCurrency ( price )
390413 formatVnPercent ( discount )
391414 formatVnNumber ( stock )
392- }
393- } )
415+ } ,
416+ { iterations : 30 } ,
417+ )
394418} )
0 commit comments