44 * Run with: bun test benchmarks/cli-performance.bench.ts
55 */
66
7- import { bench , describe } from 'bun:test'
8- import { cli } from '../src/CLI'
7+ import { describe , it } from 'bun:test'
98import { cliCache } from '../src/cache'
9+ import { cli } from '../src/CLI'
1010
1111describe ( 'CLI Performance' , ( ) => {
12- bench ( 'CLI instantiation' , ( ) => {
13- const testCli = cli ( 'test' )
12+ it ( 'CLI instantiation' , ( ) => {
13+ cli ( 'test' )
1414 } )
1515
16- bench ( 'Command registration (10 commands)' , ( ) => {
16+ it ( 'Command registration (10 commands)' , ( ) => {
1717 const testCli = cli ( 'test' )
1818 for ( let i = 0 ; i < 10 ; i ++ ) {
1919 testCli . command ( `cmd${ i } ` , `Description ${ i } ` )
2020 }
2121 } )
2222
23- bench ( 'Command registration with options (10 commands)' , ( ) => {
23+ it ( 'Command registration with options (10 commands)' , ( ) => {
2424 const testCli = cli ( 'test' )
2525 for ( let i = 0 ; i < 10 ; i ++ ) {
2626 testCli
@@ -30,7 +30,7 @@ describe('CLI Performance', () => {
3030 }
3131 } )
3232
33- bench ( 'Help text generation' , ( ) => {
33+ it ( 'Help text generation' , ( ) => {
3434 const testCli = cli ( 'test' )
3535 testCli . command ( 'test' , 'Test command' )
3636 testCli . help ( )
@@ -42,13 +42,13 @@ describe('CLI Performance', () => {
4242} )
4343
4444describe ( 'Cache Performance' , ( ) => {
45- bench ( 'Cache set (1000 items)' , ( ) => {
45+ it ( 'Cache set (1000 items)' , ( ) => {
4646 for ( let i = 0 ; i < 1000 ; i ++ ) {
4747 cliCache . set ( `key${ i } ` , `value${ i } ` , 5000 )
4848 }
4949 } )
5050
51- bench ( 'Cache get (1000 items)' , ( ) => {
51+ it ( 'Cache get (1000 items)' , ( ) => {
5252 // Pre-populate
5353 for ( let i = 0 ; i < 1000 ; i ++ ) {
5454 cliCache . set ( `key${ i } ` , `value${ i } ` , 5000 )
@@ -60,7 +60,7 @@ describe('Cache Performance', () => {
6060 }
6161 } )
6262
63- bench ( 'Cache has (1000 items)' , ( ) => {
63+ it ( 'Cache has (1000 items)' , ( ) => {
6464 // Pre-populate
6565 for ( let i = 0 ; i < 1000 ; i ++ ) {
6666 cliCache . set ( `key${ i } ` , `value${ i } ` , 5000 )
@@ -72,7 +72,7 @@ describe('Cache Performance', () => {
7272 }
7373 } )
7474
75- bench ( 'Cache cleanup (1000 items)' , ( ) => {
75+ it ( 'Cache cleanup (1000 items)' , ( ) => {
7676 // Pre-populate with expired items
7777 for ( let i = 0 ; i < 1000 ; i ++ ) {
7878 cliCache . set ( `key${ i } ` , `value${ i } ` , 1 ) // 1ms TTL
@@ -87,7 +87,7 @@ describe('Cache Performance', () => {
8787} )
8888
8989describe ( 'Namespace Extraction' , ( ) => {
90- bench ( 'Namespace extraction (1000 commands)' , ( ) => {
90+ it ( 'Namespace extraction (1000 commands)' , ( ) => {
9191 const testCli = cli ( 'test' )
9292 for ( let i = 0 ; i < 1000 ; i ++ ) {
9393 // This will trigger namespace extraction
@@ -97,14 +97,14 @@ describe('Namespace Extraction', () => {
9797} )
9898
9999describe ( 'Argument Parsing' , ( ) => {
100- bench ( 'Parse simple args (no options)' , ( ) => {
100+ it ( 'Parse simple args (no options)' , ( ) => {
101101 const testCli = cli ( 'test' )
102102 testCli . command ( 'test <arg1> <arg2>' , 'Test command' )
103103 . action ( ( ) => { } )
104104 testCli . parse ( [ 'node' , 'cli' , 'test' , 'value1' , 'value2' ] , { run : false } )
105105 } )
106106
107- bench ( 'Parse args with multiple options' , ( ) => {
107+ it ( 'Parse args with multiple options' , ( ) => {
108108 const testCli = cli ( 'test' )
109109 testCli . command ( 'test <arg>' , 'Test command' )
110110 . option ( '-f, --flag' , 'Flag' )
0 commit comments