| 732 | } |
| 733 | |
| 734 | export function printCostAnalysis( |
| 735 | screenshotResults: BenchmarkResult, |
| 736 | webmcpResults: BenchmarkResult |
| 737 | ): void { |
| 738 | const screenshotCost = |
| 739 | (screenshotResults.totalInputTokens / 1_000_000) * PRICING.inputPerMillion + |
| 740 | (screenshotResults.totalOutputTokens / 1_000_000) * PRICING.outputPerMillion; |
| 741 | |
| 742 | const webmcpCost = |
| 743 | (webmcpResults.totalInputTokens / 1_000_000) * PRICING.inputPerMillion + |
| 744 | (webmcpResults.totalOutputTokens / 1_000_000) * PRICING.outputPerMillion; |
| 745 | |
| 746 | const savings = screenshotCost - webmcpCost; |
| 747 | const savingsPct = ((savings / screenshotCost) * 100).toFixed(1); |
| 748 | |
| 749 | console.log(); |
| 750 | console.log( |
| 751 | chalk.gray( |
| 752 | ` Cost comparison (Sonnet: $${PRICING.inputPerMillion}/1M input, $${PRICING.outputPerMillion}/1M output):` |
| 753 | ) |
| 754 | ); |
| 755 | console.log( |
| 756 | chalk.gray(" Screenshot approach: ") + chalk.white(`$${screenshotCost.toFixed(6)}`) |
| 757 | ); |
| 758 | console.log( |
| 759 | chalk.gray(" WebMCP approach: ") + chalk.white(`$${webmcpCost.toFixed(6)}`) |
| 760 | ); |
| 761 | console.log( |
| 762 | chalk.gray(" Savings per task: ") + |
| 763 | chalk.green(`$${savings.toFixed(6)} (${savingsPct}%)`) |
| 764 | ); |
| 765 | |
| 766 | console.log(); |
| 767 | console.log(chalk.gray(" Extrapolated to 100 interactions:")); |
| 768 | console.log( |
| 769 | chalk.gray(" Screenshot approach: ") + chalk.white(`$${(screenshotCost * 100).toFixed(4)}`) |
| 770 | ); |
| 771 | console.log( |
| 772 | chalk.gray(" WebMCP approach: ") + chalk.white(`$${(webmcpCost * 100).toFixed(4)}`) |
| 773 | ); |
| 774 | console.log( |
| 775 | chalk.gray(" Savings: ") + |
| 776 | chalk.green(`$${(savings * 100).toFixed(4)}`) |
| 777 | ); |
| 778 | console.log(); |
| 779 | } |
| 780 | |
| 781 | export function sleep(ms: number): Promise<void> { |
| 782 | return new Promise((resolve) => setTimeout(resolve, ms)); |