Skip to main content
Glama
simple-search-benchmark.ts2.23 kB
#!/usr/bin/env node import { performance } from "node:perf_hooks"; import { createSearchForPatternTool } from "../src/tools/highlevel/fileSystemToolsFactory.ts"; import { createFastSearchForPatternTool } from "../src/tools/highlevel/fastSearchForPatternTool.ts"; async function main() { console.log("🚀 Quick Search Pattern Benchmark\n"); // Test with a simple pattern in a small directory const pattern = "function"; const path = "src/tools/finder"; console.log(`Pattern: "${pattern}"`); console.log(`Path: ${path}\n`); // Original implementation const original = createSearchForPatternTool(); console.log("Testing original implementation..."); const originalStart = performance.now(); const originalResult = await original.execute({ substringPattern: pattern, relativePath: path, restrictSearchToCodeFiles: true, contextLinesBefore: 0, contextLinesAfter: 0, maxAnswerChars: 200000, }); const originalTime = performance.now() - originalStart; const originalMatches = Object.keys(JSON.parse(originalResult)).length; console.log(` Time: ${originalTime.toFixed(2)}ms`); console.log(` Files with matches: ${originalMatches}\n`); // Fast implementation const fast = createFastSearchForPatternTool(); console.log("Testing fast implementation..."); const fastStart = performance.now(); const fastResult = await fast.execute({ substringPattern: pattern, relativePath: path, restrictSearchToCodeFiles: true, contextLinesBefore: 0, contextLinesAfter: 0, maxAnswerChars: 200000, }); const fastTime = performance.now() - fastStart; const fastMatches = Object.keys(JSON.parse(fastResult)).length; console.log(` Time: ${fastTime.toFixed(2)}ms`); console.log(` Files with matches: ${fastMatches}\n`); // Results console.log("=".repeat(50)); console.log("RESULTS:"); console.log(` Original: ${originalTime.toFixed(2)}ms`); console.log(` Fast: ${fastTime.toFixed(2)}ms`); const speedup = originalTime / fastTime; const improvement = ((originalTime - fastTime) / originalTime) * 100; console.log( ` ⚡ Speedup: ${speedup.toFixed(2)}x (${improvement.toFixed(1)}% faster)`, ); } main().catch(console.error);

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mizchi/typescript-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server