@@ -204,6 +204,48 @@ describe("simple usage", async () => {
204204 assert . ok ( bench1 . iterations >= 10 ) ;
205205 assert . ok ( bench2 . iterations >= 10 ) ;
206206 } ) ;
207+
208+ it ( "opsSecPerRun should exist when repeatSuite is 1" , async ( ) => {
209+ assert . ok (
210+ Array . isArray ( bench1 . opsSecPerRun ) ,
211+ "opsSecPerRun should be an array" ,
212+ ) ;
213+ assert . ok (
214+ Array . isArray ( bench2 . opsSecPerRun ) ,
215+ "opsSecPerRun should be an array" ,
216+ ) ;
217+ } ) ;
218+ } ) ;
219+
220+ describe ( "repeat suite" , async ( ) => {
221+ const repeatCount = 3 ;
222+ const bench = new Suite ( { reporter : noop } ) ;
223+ bench . add ( "Repeat ops test" , { repeatSuite : repeatCount } , ( ) => {
224+ // Simple operation
225+ const x = 1 + 1 ;
226+ } ) ;
227+
228+ const results = await bench . run ( ) ;
229+
230+ it ( "should include opsSecPerRun when repeatSuite is greater than 1" , async ( ) => {
231+ assert . strictEqual ( results . length , 1 ) ;
232+ assert . ok ( results [ 0 ] . opsSec !== undefined , "opsSec should be defined" ) ;
233+ assert . ok (
234+ Array . isArray ( results [ 0 ] . opsSecPerRun ) ,
235+ "opsSecPerRun should be an array" ,
236+ ) ;
237+ assert . strictEqual (
238+ results [ 0 ] . opsSecPerRun . length ,
239+ repeatCount ,
240+ `opsSecPerRun should have ${ repeatCount } elements` ,
241+ ) ;
242+ for ( const opsSec of results [ 0 ] . opsSecPerRun ) {
243+ assert . ok (
244+ typeof opsSec === "number" && ! Number . isNaN ( opsSec ) ,
245+ "each element should be a valid number" ,
246+ ) ;
247+ }
248+ } ) ;
207249} ) ;
208250
209251describe ( "throws when a benchmark task throw" , async ( ) => {
0 commit comments