* Test performance with large files of different line ending types * This is a modified version to work with the 100-line limit
()
| 3 | * This is a modified version to work with the 100-line limit |
| 4 | */ |
| 5 | async function testLargeFilePerformance() { |
| 6 | console.log('\nTest 6: Performance with large files'); |
| 7 | |
| 8 | const LARGE_FILE_LF = path.join(TEST_DIR, 'large_lf.txt'); |
| 9 | const LARGE_FILE_CRLF = path.join(TEST_DIR, 'large_crlf.txt'); |
| 10 | |
| 11 | try { |
| 12 | // Create large test files (but stay within 100-line limit) |
| 13 | const lines = Array(90).fill('This is a line in a large file.\n'); |
| 14 | lines[45] = 'TARGET LINE TO FIND AND REPLACE\n'; |
| 15 | |
| 16 | // LF version - write in smaller chunks to respect line limit |
| 17 | // First chunk |
| 18 | await fs.writeFile(LARGE_FILE_LF, lines.join('')); |
| 19 | |
| 20 | // CRLF version - also respect line limit |
| 21 | const crlfLines = lines.map(line => line.replace('\n', '\r\n')); |
| 22 | await fs.writeFile(LARGE_FILE_CRLF, crlfLines.join('')); |
| 23 | |
| 24 | // Test LF file |
| 25 | const startLF = Date.now(); |
| 26 | let result = await handleEditBlock({ |
| 27 | file_path: LARGE_FILE_LF, |
| 28 | old_string: 'TARGET LINE TO FIND AND REPLACE', |
| 29 | new_string: 'REPLACED TARGET LINE IN LF FILE', |
| 30 | expected_replacements: 1 |
| 31 | }); |
| 32 | const timeLF = Date.now() - startLF; |
| 33 | |
| 34 | assert.ok( |
| 35 | result.content[0].text.includes('Successfully applied 1 edit'), |
| 36 | 'Should handle large LF file' |
| 37 | ); |
| 38 | |
| 39 | // Test CRLF file |
| 40 | const startCRLF = Date.now(); |
| 41 | result = await handleEditBlock({ |
| 42 | file_path: LARGE_FILE_CRLF, |
| 43 | old_string: 'TARGET LINE TO FIND AND REPLACE', |
| 44 | new_string: 'REPLACED TARGET LINE IN CRLF FILE', |
| 45 | expected_replacements: 1 |
| 46 | }); |
| 47 | const timeCRLF = Date.now() - startCRLF; |
| 48 | |
| 49 | assert.ok( |
| 50 | result.content[0].text.includes('Successfully applied 1 edit'), |
| 51 | 'Should handle large CRLF file' |
| 52 | ); |
| 53 | |
| 54 | console.log(`✓ Performance test passed (LF: ${timeLF}ms, CRLF: ${timeCRLF}ms)`); |
| 55 | } catch (error) { |
| 56 | console.error('❌ Test failed:', error); |
| 57 | throw error; |
| 58 | } |
| 59 | } |
nothing calls this directly
no test coverage detected