@@ -12,15 +12,15 @@ let sqlparserRs = null;
1212let nodeSqlParser = null ;
1313
1414async function initParsers ( ) {
15- const rs = await import ( 'sqlparser-rs ' ) ;
15+ const rs = await import ( 'sqlparser-ts ' ) ;
1616 await rs . ready ( ) ;
1717 sqlparserRs = rs ;
1818
1919 const node = await import ( 'node-sql-parser' ) ;
2020 nodeSqlParser = new ( node . default ?. Parser || node . Parser ) ( ) ;
2121}
2222
23- // sqlparser-rs methods
23+ // sqlparser-ts methods
2424const rsMethods = {
2525 parse : ( sql , dialect ) => sqlparserRs . Parser . parse ( sql , dialect ) ,
2626 parseToJson : ( sql , dialect ) => sqlparserRs . Parser . parseToJson ( sql , dialect ) ,
@@ -49,7 +49,7 @@ const nodeMethods = {
4949// Methods supported by both parsers (for comparison)
5050const comparableMethods = [ 'parse' , 'format' ] ;
5151
52- // Methods only in sqlparser-rs (benchmark alone)
52+ // Methods only in sqlparser-ts (benchmark alone)
5353const rsOnlyMethods = [ 'parseToJson' , 'parseToString' , 'validate' ] ;
5454
5555// ============================================================
@@ -94,7 +94,7 @@ async function runVerify(options = {}) {
9494 }
9595
9696 const total = testQueries [ level ] . length ;
97- console . log ( ` ${ level . padEnd ( 8 ) } : sqlparser-rs ${ rsSuccess } /${ total } , node-sql-parser ${ nodeSuccess } /${ total } ` ) ;
97+ console . log ( ` ${ level . padEnd ( 8 ) } : sqlparser-ts ${ rsSuccess } /${ total } , node-sql-parser ${ nodeSuccess } /${ total } ` ) ;
9898 }
9999 }
100100 }
@@ -104,7 +104,7 @@ async function runVerify(options = {}) {
104104 console . log ( 'SUMMARY' ) ;
105105 console . log ( '=' . repeat ( 70 ) ) ;
106106
107- console . log ( '\n| Dialect | Command | Level | sqlparser-rs | node-sql-parser |' ) ;
107+ console . log ( '\n| Dialect | Command | Level | sqlparser-ts | node-sql-parser |' ) ;
108108 console . log ( '|---------|--------|-------|--------------|-----------------|' ) ;
109109
110110 for ( const d of dialectsToTest ) {
@@ -150,7 +150,7 @@ function updateReadmeCompatibility(allResults, dialectsToTest) {
150150
151151Parsing success rate across ${ numQueries } test queries per dialect:
152152
153- | Dialect | Level | sqlparser-rs | node-sql-parser |
153+ | Dialect | Level | sqlparser-ts | node-sql-parser |
154154|---------|-------|--------------|-----------------|
155155` ;
156156
@@ -199,7 +199,7 @@ Parsing success rate across ${numQueries} test queries per dialect:
199199 }
200200 }
201201
202- compatibilitySection += `\n**Key findings:**\n- **sqlparser-rs **: Near 100% compatibility across all dialects\n` ;
202+ compatibilitySection += `\n**Key findings:**\n- **sqlparser-ts **: Near 100% compatibility across all dialects\n` ;
203203
204204 if ( minNodeSuccess < 95 ) {
205205 compatibilitySection += `- **node-sql-parser**: Struggles with ${ dialectNames [ worstDialect ] } ${ worstLevel } queries (${ minNodeSuccess . toFixed ( 0 ) } % success rate)\n` ;
@@ -227,10 +227,10 @@ async function runBenchmark(options = {}) {
227227 const { iterations = 10000 , dialect = 'all' , method = 'all' } = options ;
228228
229229 console . log ( '=' . repeat ( 70 ) ) ;
230- console . log ( 'SQL Parser Benchmark: sqlparser-rs vs node-sql-parser' ) ;
230+ console . log ( 'SQL Parser Benchmark: sqlparser-ts vs node-sql-parser' ) ;
231231 console . log ( '=' . repeat ( 70 ) ) ;
232232 console . log ( `\nComparable methods: ${ comparableMethods . join ( ', ' ) } ` ) ;
233- console . log ( `sqlparser-rs only: ${ rsOnlyMethods . join ( ', ' ) } ` ) ;
233+ console . log ( `sqlparser-ts only: ${ rsOnlyMethods . join ( ', ' ) } ` ) ;
234234 console . log ( `Dialects: ${ dialect === 'all' ? dialects . join ( ', ' ) : dialect } ` ) ;
235235 console . log ( `Iterations: ${ iterations } ` ) ;
236236
@@ -272,7 +272,7 @@ async function runBenchmark(options = {}) {
272272 const levelQueries = testQueries [ level ] ;
273273 results [ d ] . queries [ level ] = levelQueries . length ;
274274
275- // sqlparser-rs
275+ // sqlparser-ts
276276 let start = performance . now ( ) ;
277277 for ( let i = 0 ; i < iterations ; i ++ ) {
278278 for ( const q of levelQueries ) {
@@ -307,9 +307,9 @@ async function runBenchmark(options = {}) {
307307 console . log ( ` ${ 'TOTAL' . padEnd ( 8 ) } : rs ${ results [ d ] [ m ] . rs . total . toFixed ( 0 ) . padStart ( 6 ) } ms | node ${ results [ d ] [ m ] . node . total . toFixed ( 0 ) . padStart ( 6 ) } ms | ${ totalSpeedup } x faster` ) ;
308308 }
309309
310- // Benchmark sqlparser-rs only methods
310+ // Benchmark sqlparser-ts only methods
311311 for ( const m of rsOnlyMethods ) {
312- console . log ( `\n### ${ m . toUpperCase ( ) } (sqlparser-rs only)` ) ;
312+ console . log ( `\n### ${ m . toUpperCase ( ) } (sqlparser-ts only)` ) ;
313313 results [ d ] [ m ] = { rs : { } } ;
314314
315315 for ( const level of [ 'simple' , 'medium' , 'complex' ] ) {
@@ -423,13 +423,13 @@ function saveSizeResults({ sqlparserTotalSize, sqlparserWasmSize, sqlparserDistS
423423| Package | Size | Reduction |
424424|------------------|-----------|-----------------|
425425| node-sql-parser | ${ formatSize ( nodeSqlParserSize ) . padEnd ( 9 ) } | - |
426- | sqlparser-rs | ${ formatSize ( sqlparserTotalSize ) . padEnd ( 9 ) } | ${ reduction } % (${ ratio } x) |
426+ | sqlparser-ts | ${ formatSize ( sqlparserTotalSize ) . padEnd ( 9 ) } | ${ reduction } % (${ ratio } x) |
427427
428428Breakdown:
429429| Package | Component | Size |
430430|-----------------|-----------|-----------|
431- | sqlparser-rs | wasm/ | ${ formatSize ( sqlparserWasmSize ) . padEnd ( 9 ) } |
432- | sqlparser-rs | dist/ | ${ formatSize ( sqlparserDistSize ) . padEnd ( 9 ) } |
431+ | sqlparser-ts | wasm/ | ${ formatSize ( sqlparserWasmSize ) . padEnd ( 9 ) } |
432+ | sqlparser-ts | dist/ | ${ formatSize ( sqlparserDistSize ) . padEnd ( 9 ) } |
433433` . split ( '\n' ) ;
434434 writeResultsFile ( sections ) ;
435435}
@@ -442,7 +442,7 @@ function saveSpeedResults(results, iterations, dialectsToTest) {
442442
443443 // Time by Command and Dialect
444444 let timeTable = `
445- | Command | Dialect | sqlparser-rs | node-sql-parser | Speedup |
445+ | Command | Dialect | sqlparser-ts | node-sql-parser | Speedup |
446446|---------|------------|--------------|-----------------|---------|
447447` ;
448448 for ( const m of comparableMethods ) {
@@ -473,7 +473,7 @@ async function runSize() {
473473 const nodeSqlParserPath = join ( process . cwd ( ) , 'node_modules' , 'node-sql-parser' ) ;
474474 const nodeSqlParserSize = getDirectorySize ( nodeSqlParserPath ) ;
475475
476- console . log ( `\nsqlparser-rs : ${ formatSize ( sqlparserTotalSize ) } ` ) ;
476+ console . log ( `\nsqlparser-ts : ${ formatSize ( sqlparserTotalSize ) } ` ) ;
477477 console . log ( ` - wasm/: ${ formatSize ( sqlparserWasmSize ) } ` ) ;
478478 console . log ( ` - dist/: ${ formatSize ( sqlparserDistSize ) } ` ) ;
479479
@@ -526,7 +526,7 @@ async function runBench(options = {}) {
526526 config : {
527527 type : 'bar' ,
528528 data : {
529- labels : [ 'node-sql-parser' , 'sqlparser-rs ' ] ,
529+ labels : [ 'node-sql-parser' , 'sqlparser-ts ' ] ,
530530 datasets : [ {
531531 label : 'Package Size (MB)' ,
532532 data : [ ( sizeResults . nodeSqlParser / ( 1024 * 1024 ) ) . toFixed ( 1 ) , ( sizeResults . sqlparserRs / ( 1024 * 1024 ) ) . toFixed ( 1 ) ] ,
@@ -572,7 +572,7 @@ async function runBench(options = {}) {
572572 data : {
573573 labels : combinedLabels ,
574574 datasets : [
575- { label : 'sqlparser-rs (μs)' , data : rsData , backgroundColor : gray . dark } ,
575+ { label : 'sqlparser-ts (μs)' , data : rsData , backgroundColor : gray . dark } ,
576576 { label : 'node-sql-parser (μs)' , data : nodeData , backgroundColor : gray . light }
577577 ]
578578 } ,
@@ -643,23 +643,23 @@ function updateReadme(sizeResults, speedResults, iterations) {
643643 node : ( speedResults . mysql . format . node . total + speedResults . postgresql . format . node . total + speedResults . sqlite . format . node . total ) / 3 ,
644644 } ;
645645
646- const readme = `# Benchmark: sqlparser-rs vs node-sql-parser
646+ const readme = `# Benchmark: sqlparser-ts vs node-sql-parser
647647
648- Performance comparison between **sqlparser-rs ** and **node-sql-parser**.
648+ Performance comparison between **sqlparser-ts ** and **node-sql-parser**.
649649
650650## Summary
651651
652- | Metric | sqlparser-rs | node-sql-parser | Winner |
652+ | Metric | sqlparser-ts | node-sql-parser | Winner |
653653|--------|-------------|-----------------|--------|
654- | Package Size | **${ formatSize ( sizeResults . sqlparserRs ) } ** | ${ formatSize ( sizeResults . nodeSqlParser ) } | sqlparser-rs (**${ sizeResults . ratio } x smaller**) |
655- | Parse (avg) | **${ fmtMs ( parseAvg . rs ) } ** | ${ fmtMs ( parseAvg . node ) } | sqlparser-rs (**${ ( parseAvg . node / parseAvg . rs ) . toFixed ( 2 ) } x faster**) |
656- | Format (avg) | **${ fmtMs ( formatAvg . rs ) } ** | ${ fmtMs ( formatAvg . node ) } | sqlparser-rs (**${ ( formatAvg . node / formatAvg . rs ) . toFixed ( 2 ) } x faster**) |
654+ | Package Size | **${ formatSize ( sizeResults . sqlparserRs ) } ** | ${ formatSize ( sizeResults . nodeSqlParser ) } | sqlparser-ts (**${ sizeResults . ratio } x smaller**) |
655+ | Parse (avg) | **${ fmtMs ( parseAvg . rs ) } ** | ${ fmtMs ( parseAvg . node ) } | sqlparser-ts (**${ ( parseAvg . node / parseAvg . rs ) . toFixed ( 2 ) } x faster**) |
656+ | Format (avg) | **${ fmtMs ( formatAvg . rs ) } ** | ${ fmtMs ( formatAvg . node ) } | sqlparser-ts (**${ ( formatAvg . node / formatAvg . rs ) . toFixed ( 2 ) } x faster**) |
657657
658658## Test Configuration
659659
660660- **3 Dialects**: MySQL, PostgreSQL, SQLite
661661- **Comparable methods**: \`parse\`, \`format\` (both parsers support)
662- - **sqlparser-rs only**: \`parseToJson\`, \`parseToString\`, \`validate\`
662+ - **sqlparser-ts only**: \`parseToJson\`, \`parseToString\`, \`validate\`
663663- **3 Complexity Levels**: Simple (${ speedResults . mysql . queries . simple } ), Medium (${ speedResults . mysql . queries . medium } ), Complex (${ speedResults . mysql . queries . complex } )
664664- **${ numQueries } queries per dialect**
665665- **${ fmt ( iterations ) } iterations per query**
@@ -671,13 +671,13 @@ Performance comparison between **sqlparser-rs** and **node-sql-parser**.
671671| Package | Size | Reduction |
672672|---------|------|-----------|
673673| node-sql-parser | ${ formatSize ( sizeResults . nodeSqlParser ) } | - |
674- | **sqlparser-rs ** | **${ formatSize ( sizeResults . sqlparserRs ) } ** | **${ sizeResults . reduction } % smaller** |
674+ | **sqlparser-ts ** | **${ formatSize ( sizeResults . sqlparserRs ) } ** | **${ sizeResults . reduction } % smaller** |
675675
676676## Time by Command and Dialect
677677
678678
679679
680- | Command | Dialect | sqlparser-rs | Avg/Call | node-sql-parser | Avg/Call | Speedup |
680+ | Command | Dialect | sqlparser-ts | Avg/Call | node-sql-parser | Avg/Call | Speedup |
681681|---------|---------|-------------|----------|-----------------|----------|---------|
682682| Parse | MySQL | ${ fmtMs ( speedResults . mysql . parse . rs . total ) } | ${ fmtAvgCall ( speedResults . mysql . parse . rs . total ) } | ${ fmtMs ( speedResults . mysql . parse . node . total ) } | ${ fmtAvgCall ( speedResults . mysql . parse . node . total ) } | **${ ( speedResults . mysql . parse . node . total / speedResults . mysql . parse . rs . total ) . toFixed ( 2 ) } x** |
683683| Parse | PostgreSQL | ${ fmtMs ( speedResults . postgresql . parse . rs . total ) } | ${ fmtAvgCall ( speedResults . postgresql . parse . rs . total ) } | ${ fmtMs ( speedResults . postgresql . parse . node . total ) } | ${ fmtAvgCall ( speedResults . postgresql . parse . node . total ) } | **${ ( speedResults . postgresql . parse . node . total / speedResults . postgresql . parse . rs . total ) . toFixed ( 2 ) } x** |
@@ -686,7 +686,7 @@ Performance comparison between **sqlparser-rs** and **node-sql-parser**.
686686| Format | PostgreSQL | ${ fmtMs ( speedResults . postgresql . format . rs . total ) } | ${ fmtAvgCall ( speedResults . postgresql . format . rs . total ) } | ${ fmtMs ( speedResults . postgresql . format . node . total ) } | ${ fmtAvgCall ( speedResults . postgresql . format . node . total ) } | **${ ( speedResults . postgresql . format . node . total / speedResults . postgresql . format . rs . total ) . toFixed ( 2 ) } x** |
687687| Format | SQLite | ${ fmtMs ( speedResults . sqlite . format . rs . total ) } | ${ fmtAvgCall ( speedResults . sqlite . format . rs . total ) } | ${ fmtMs ( speedResults . sqlite . format . node . total ) } | ${ fmtAvgCall ( speedResults . sqlite . format . node . total ) } | **${ ( speedResults . sqlite . format . node . total / speedResults . sqlite . format . rs . total ) . toFixed ( 2 ) } x** |
688688
689- | Command (sqlparser-rs only) | MySQL | Avg/Call | PostgreSQL | Avg/Call | SQLite | Avg/Call |
689+ | Command (sqlparser-ts only) | MySQL | Avg/Call | PostgreSQL | Avg/Call | SQLite | Avg/Call |
690690|----------------------------|-------|----------|------------|----------|--------|----------|
691691| parseToJson | ${ fmtMs ( speedResults . mysql . parseToJson . rs . total ) } | ${ fmtAvgCall ( speedResults . mysql . parseToJson . rs . total ) } | ${ fmtMs ( speedResults . postgresql . parseToJson . rs . total ) } | ${ fmtAvgCall ( speedResults . postgresql . parseToJson . rs . total ) } | ${ fmtMs ( speedResults . sqlite . parseToJson . rs . total ) } | ${ fmtAvgCall ( speedResults . sqlite . parseToJson . rs . total ) } |
692692| parseToString | ${ fmtMs ( speedResults . mysql . parseToString . rs . total ) } | ${ fmtAvgCall ( speedResults . mysql . parseToString . rs . total ) } | ${ fmtMs ( speedResults . postgresql . parseToString . rs . total ) } | ${ fmtAvgCall ( speedResults . postgresql . parseToString . rs . total ) } | ${ fmtMs ( speedResults . sqlite . parseToString . rs . total ) } | ${ fmtAvgCall ( speedResults . sqlite . parseToString . rs . total ) } |
@@ -696,7 +696,7 @@ Performance comparison between **sqlparser-rs** and **node-sql-parser**.
696696
697697Parsing success rate across ${ numQueries } test queries per dialect:
698698
699- | Dialect | Level | sqlparser-rs | node-sql-parser |
699+ | Dialect | Level | sqlparser-ts | node-sql-parser |
700700|---------|-------|--------------|-----------------|
701701| MySQL | simple | 55/55 (100%) | 55/55 (100%) |
702702| MySQL | medium | 55/55 (100%) | 55/55 (100%) |
@@ -709,7 +709,7 @@ Parsing success rate across ${numQueries} test queries per dialect:
709709| SQLite | complex | 53/53 (100%) | 33/53 (62%) |
710710
711711**Key findings:**
712- - **sqlparser-rs **: Near 100% compatibility across all dialects
712+ - **sqlparser-ts **: Near 100% compatibility across all dialects
713713- **node-sql-parser**: Struggles with SQLite complex queries (62% success rate)
714714
715715## CLI Commands
@@ -729,7 +729,7 @@ node cli.js help # Show help
729729
730730## Conclusion
731731
732- **sqlparser-rs ** significantly outperforms **node-sql-parser**:
732+ **sqlparser-ts ** significantly outperforms **node-sql-parser**:
733733
734734| Advantage | Improvement |
735735|-----------|-------------|
@@ -738,7 +738,7 @@ node cli.js help # Show help
738738| Format speed | **${ ( formatAvg . node / formatAvg . rs ) . toFixed ( 2 ) } x faster** (average) |
739739| Compatibility | **~100%** vs ~90% (node-sql-parser fails on complex SQLite) |
740740
741- The performance advantage comes from sqlparser-rs being written in Rust and compiled to WebAssembly, providing near-native performance while maintaining a minimal bundle size.
741+ The performance advantage comes from sqlparser-ts being written in Rust and compiled to WebAssembly, providing near-native performance while maintaining a minimal bundle size.
742742` ;
743743
744744 writeFileSync ( join ( process . cwd ( ) , 'README.md' ) , readme ) ;
@@ -810,7 +810,7 @@ Examples:
810810Test Configuration:
811811 - 3 dialects: MySQL, PostgreSQL, SQLite
812812 - Comparable methods: parse, format (both parsers)
813- - sqlparser-rs only: parseToJson, parseToString, validate
813+ - sqlparser-ts only: parseToJson, parseToString, validate
814814 - 3 complexity levels: simple, medium, complex
815815 - ~163 queries per dialect
816816` ) ;
0 commit comments