{"id":31033302,"url":"https://github.com/yinxulai/ait","last_synced_at":"2026-05-25T07:01:15.426Z","repository":{"id":312992205,"uuid":"1049004293","full_name":"yinxulai/ait","owner":"yinxulai","description":"批量测试符合 OpenAI 协议和 Anthropic 协议的 AI 模型性能指标。支持 TTFT（首字节时间）、TPS（吞吐量）、网络延迟等关键性能指标的测量，提供多模型对比测试和详细的性能报告生成功能。","archived":false,"fork":false,"pushed_at":"2026-05-24T15:26:13.000Z","size":6108,"stargazers_count":31,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-24T17:17:59.123Z","etag":null,"topics":["ai","llm","tps","ttft"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yinxulai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-02T10:49:41.000Z","updated_at":"2026-05-06T09:21:12.000Z","dependencies_parsed_at":"2025-09-03T09:25:46.152Z","dependency_job_id":"d0d5012f-4563-4f06-859d-c91770b1d015","html_url":"https://github.com/yinxulai/ait","commit_stats":null,"previous_names":["yinxulai/ait"],"tags_count":30,"template":false,"template_full_name":"yinxulai/go-template","purl":"pkg:github/yinxulai/ait","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinxulai%2Fait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinxulai%2Fait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinxulai%2Fait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinxulai%2Fait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yinxulai","download_url":"https://codeload.github.com/yinxulai/ait/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinxulai%2Fait/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33464012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T06:32:55.349Z","status":"ssl_error","status_checked_at":"2026-05-25T06:32:35.322Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","llm","tps","ttft"],"created_at":"2025-09-14T01:43:39.573Z","updated_at":"2026-05-25T07:01:15.419Z","avatar_url":"https://github.com/yinxulai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AIT - AI 模型性能测试工具\n\n[![test](https://github.com/yinxulai/ait/actions/workflows/test.yaml/badge.svg)](https://github.com/yinxulai/ait/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/yinxulai/ait/graph/badge.svg?token=WO1ZIWNGJ8)](https://codecov.io/gh/yinxulai/ait)\n\n一个强大的 CLI 工具，用于批量测试符合 OpenAI 协议和 Anthropic 协议的 AI 模型性能指标。支持 TTFT（首字节时间）、TPS（吞吐量）、网络延迟等关键性能指标的测量，提供多模型对比测试和详细的性能报告生成功能。\n\n## ✨ 功能特性\n\n- 🚀 **多协议支持**: 支持 OpenAI 和 Anthropic 协议\n- 🎯 **多模型测试**: 支持同时测试多个模型，用逗号分割模型名称\n- 🤖 **智能协议推断**: 根据环境变量自动推断协议类型，简化使用\n- 📊 **实时进度条**: 测试过程可视化显示，支持多模型总进度\n- 🎨 **彩色输出**: 美观的终端界面\n- 📋 **表格化结果**: 清晰的结果展示，支持单模型和多模型对比\n- ⚡ **并发测试**: 支持自定义并发数压力测试\n- ⏱️ **超时控制**: 可配置请求超时时间，提高测试稳定性\n- 📈 **详细统计**: TTFT、TPS、最小/最大/平均响应时间\n- 📄 **多格式报告**: 支持生成 JSON 和 CSV 格式的详细测试报告\n- 🌐 **网络指标**: 包含 DNS、连接、TLS 握手等网络性能指标\n- 🔄 **流式支持**: 默认支持流式响应，更真实的测试场景\n\n![AIT 工具使用截图](snapshot/snapsho.png)\n\n## 🛠️ 安装和使用\n\n### 方式一：下载预编译二进制文件（推荐）\n\n从 [Releases 页面](https://github.com/yinxulai/ait/releases) 下载适合您平台的预编译二进制文件：\n\n#### Linux/macOS 一键安装脚本（自动识别架构）\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/yinxulai/ait/main/scripts/install-ait.sh | bash\n```\n\n\u003e 脚本会自动识别操作系统（Linux/macOS）和架构（`x86_64`, `aarch64`, `armv7l`, `i386`），下载最新版本并安装到 `/usr/local/bin`。如需自定义安装目录，可先下载脚本再执行：`curl -fsSL https://raw.githubusercontent.com/yinxulai/ait/main/scripts/install-ait.sh -o install-ait.sh \u0026\u0026 INSTALL_DIR=$HOME/.local/bin bash install-ait.sh`。\n\n```bash\n# Linux (x64)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-linux-amd64\nchmod +x ait-linux-amd64\nsudo mv ait-linux-amd64 /usr/local/bin/ait\n\n# Linux (ARM64)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-linux-arm64\nchmod +x ait-linux-arm64\nsudo mv ait-linux-arm64 /usr/local/bin/ait\n\n# Linux (ARM)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-linux-arm\nchmod +x ait-linux-arm\nsudo mv ait-linux-arm /usr/local/bin/ait\n\n# Linux (386)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-linux-386\nchmod +x ait-linux-386\nsudo mv ait-linux-386 /usr/local/bin/ait\n\n# macOS (Intel)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-darwin-amd64\nchmod +x ait-darwin-amd64\nsudo mv ait-darwin-amd64 /usr/local/bin/ait\n\n# macOS (Apple Silicon)\nwget https://github.com/yinxulai/ait/releases/latest/download/ait-darwin-arm64\nchmod +x ait-darwin-arm64\nsudo mv ait-darwin-arm64 /usr/local/bin/ait\n\n# Windows (x64) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/ait-windows-amd64.exe\" -OutFile \"ait.exe\"\n# 将 ait.exe 移动到您的 PATH 中\n\n# Windows (ARM64) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/ait-windows-arm64.exe\" -OutFile \"ait.exe\"\n# 将 ait.exe 移动到您的 PATH 中\n\n# Windows (386) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/ait-windows-386.exe\" -OutFile \"ait.exe\"\n# 将 ait.exe 移动到您的 PATH 中\n```\n\n### 方式二：从源码编译\n\n```bash\n# 克隆项目\ngit clone https://github.com/yinxulai/ait.git\ncd ait\n\n# 编译（默认版本为 dev）\nmake build\n\n# 或者指定版本号编译\nmake build VERSION=v1.0.0\n\n# 直接用 go build\ngo build -o bin/ait ./cmd/ait/\n\n# 查看版本信息\n./bin/ait --version\n```\n\n## 🚀 快速开始\n\n### 查看版本信息\n\n```bash\n# 查看完整版本信息\nait --version\n\n# 输出示例：\n# ait version v1.0.0\n# Git Commit: 5ad79fb\n# Build Time: 2025-12-08_10:30:15\n```\n\n### OpenAI 协议测试\n\n```bash\n# 使用 --model 测试单个模型\nait --protocol=openai --baseUrl=https://api.openai.com/v1 --apiKey=sk-your-api-key --model=gpt-3.5-turbo --concurrency=3 --count=10 --report\n\n# 或使用 --models（支持多个模型）\nait --protocol=openai --baseUrl=https://api.openai.com/v1 --apiKey=sk-your-api-key --models=gpt-3.5-turbo --concurrency=3 --count=10 --report\n\n# 使用环境变量可以省略 protocol 参数（会自动推断）\nexport OPENAI_API_KEY=\"sk-your-api-key\"\nexport OPENAI_BASE_URL=\"https://api.openai.com/v1\"\nait --models=gpt-3.5-turbo --concurrency=3 --count=10 --report\n```\n\n### Anthropic 协议测试\n\n```bash\nait --protocol=anthropic --baseUrl=https://api.anthropic.com --apiKey=sk-ant-your-api-key --models=claude-3-haiku-20240307 --concurrency=2 --count=5 --report\n\n# 使用环境变量可以省略 protocol 参数（会自动推断）\nexport ANTHROPIC_API_KEY=\"sk-ant-your-api-key\"\nexport ANTHROPIC_BASE_URL=\"https://api.anthropic.com\"\nait --models=claude-3-haiku-20240307 --concurrency=2 --count=5 --report\n```\n\n### 多模型比较测试\n\n```bash\n# 同时测试多个 OpenAI 模型\nait --protocol=openai --baseUrl=https://api.openai.com/v1 --apiKey=sk-your-api-key --models=\"gpt-3.5-turbo,gpt-4,gpt-4-turbo\" --concurrency=3 --count=10 --report\n\n# 测试最新的 Claude 和 Gemini 模型（使用环境变量）\nexport OPENAI_API_KEY=\"sk-your-key\"\nait --models=claude-4.1-opus,claude-4.0-sonnet,claude-3.5-haiku,gemini-2.5-pro,gemini-2.0-flash --concurrency=3 --count=5 --report\n\n# 多模型测试会为每个模型生成独立的 JSON 和 CSV 报告\n# 同时还会生成一个综合比较的 CSV 报告方便对比分析\n```\n\n### 本地模型测试（如 Ollama）\n\n```bash\nait --protocol=openai --baseUrl=http://localhost:11434/v1 --apiKey=dummy --models=llama2 --concurrency=1 --count=3\n```\n\n## 🔧 环境变量支持\n\n为了简化使用，AIT 支持通过环境变量自动配置 API 密钥和服务地址：\n\n### OpenAI 协议\n\n```bash\nexport OPENAI_API_KEY=\"sk-your-api-key\"\nexport OPENAI_BASE_URL=\"https://api.openai.com/v1\"\n\n# 简化使用，protocol 会自动推断为 openai\n# 使用 --model 测试单个模型\nait --model=gpt-3.5-turbo --count=10 --report\n\n# 使用 --models 测试多个模型\nait --models=gpt-3.5-turbo,gpt-4 --count=10 --report\n```\n\n### Anthropic 协议\n\n```bash\nexport ANTHROPIC_API_KEY=\"sk-ant-your-api-key\"\nexport ANTHROPIC_BASE_URL=\"https://api.anthropic.com\"\n\n# 简化使用，protocol 会自动推断为 anthropic\nait --models=claude-3-haiku-20240307 --count=5 --report\n```\n\n## 📝 管道输入和文件支持\n\nAIT 提供了灵活的 prompt 输入方式，满足不同的测试需求：\n\n### 输入方式优先级\n\n1. **用户明确指定的 `--prompt-length` 参数**（最高优先级，用于快速生成指定长度的测试内容）\n2. **用户明确指定的 `--prompt-file` 参数**（高优先级）\n3. **用户明确指定的 `--prompt` 参数**（中高优先级）\n4. **管道输入**（中等优先级，仅当未使用上述参数时生效）\n5. **默认值**（最低优先级）\n\n### 1. 快速生成指定长度的测试内容\n\n使用 `--prompt-length` 参数可以快速生成指定字符长度的测试 prompt，无需准备测试文件：\n\n```bash\n# 生成 100 个字符的测试内容\nait --models=gpt-4 --prompt-length=100 --count=5\n\n# 生成 1000 个字符的测试内容进行压力测试\nait --models=gpt-4,claude-3-sonnet --prompt-length=1000 --count=20 --concurrency=5 --report\n\n# 测试不同长度的性能表现\nait --models=gpt-4 --prompt-length=500 --count=10 --report\nait --models=gpt-4 --prompt-length=2000 --count=10 --report\n```\n\n\u003e **提示**：生成的内容是有意义的中文文本片段，而不是随机字符，更接近真实使用场景。\n\n### 2. 直接字符串输入\n\n```bash\n# 直接指定 prompt 内容\nait --models=gpt-4 --prompt=\"分析人工智能的发展前景\" --count=3\n```\n\n### 3. 从文件读取 prompt\n\n使用 `--prompt-file` 参数指定文件路径，支持单文件和通配符：\n\n```bash\n# 单个文件\nait --models=gpt-4 --prompt-file=prompts/complex_prompt.txt --count=5\n\n# 通配符匹配多个文件（随机选择）\nait --models=gpt-4 --prompt-file=\"prompts/*.txt\" --count=10\n\n# 指定模式的文件\nait --models=claude-3-sonnet --prompt-file=\"test_cases/scenario_*.txt\" --count=5\n```\n\n### 4. 管道输入\n\n当未使用 `--prompt`、`--prompt-file` 或 `--prompt-length` 参数时，支持通过管道输入：\n\n```bash\n# 基本管道输入\necho \"请分析这段代码的性能优化建议\" | ait --models=gpt-4 --count=3\n\n# 从文件输入\ncat complex_prompt.txt | ait --models=claude-3-sonnet --count=5\n\n# 多行复杂 prompt\ncat \u003c\u003c EOF | ait --models=gpt-4,claude-3-sonnet --count=3 --report\n请分析以下代码，并提供：\n1. 性能优化建议\n2. 安全性评估  \n3. 可读性改进\n4. 最佳实践建议\n\n\\`\\`\\`python\ndef process_data(data):\n    result = []\n    for item in data:\n        if item \u003e 0:\n            result.append(item * 2)\n    return result\n\\`\\`\\`\nEOF\n```\n\n### 5. 参数组合使用\n\n```bash\n# prompt-length 优先级最高，用于快速测试\nait --models=gpt-4 --prompt-length=500 --count=10 --report\n\n# 使用文件输入（优先级：prompt-length \u003e prompt-file \u003e prompt \u003e 管道）\nait --models=gpt-4 --prompt-file=\"prompts/*.txt\" --count=5 --report\n\n# 结合环境变量使用\nexport OPENAI_API_KEY=\"sk-your-key\"\nait --models=gpt-4,claude-3-sonnet --prompt-file=\"test_cases/*.txt\" --count=10\n```\n\n### 6. 批量测试场景\n\n```bash\n# 创建多个测试场景文件\nmkdir -p test_prompts\necho \"请解释机器学习的基本概念\" \u003e test_prompts/ml_basic.txt\necho \"分析深度学习的应用场景\" \u003e test_prompts/dl_applications.txt\necho \"比较不同优化算法的特点\" \u003e test_prompts/optimization.txt\n\n# 使用通配符随机测试多个场景\nait --models=gpt-4,claude-3-sonnet --prompt-file=\"test_prompts/*.txt\" --count=20 --report\n```\n\n### 重要说明\n\n- **参数优先级**：`--prompt-length` \u003e `--prompt-file` \u003e `--prompt` \u003e 管道输入 \u003e 默认值\n- **快速测试**：使用 `--prompt-length` 可以快速生成指定长度的测试内容，无需准备文件\n- **文件随机选择**：使用通配符时，每次请求会随机选择匹配的文件\n- **错误处理**：文件不存在或读取失败时会显示警告并使用默认 prompt\n\n## 📋 命令行参数\n\n| 参数 | 描述 | 默认值 | 必填 |\n| :--- | :--- | :--- | :---: |\n| `--version` | 显示版本信息（包括 Git Commit 和构建时间） | - | ❌ |\n| `--protocol` | 协议类型 (`openai`/`anthropic`) | 根据环境变量自动推断 | ❌ |\n| `--baseUrl` | 服务地址\u003cbr/\u003e支持环境变量：`OPENAI_BASE_URL` 或 `ANTHROPIC_BASE_URL` | - | ✅ |\n| `--apiKey` | API 密钥\u003cbr/\u003e支持环境变量：`OPENAI_API_KEY` 或 `ANTHROPIC_API_KEY` | - | ✅ |\n| `--model` | 单个模型名称\u003cbr/\u003e如：`gpt-4`（不支持多个模型） | - | ❌ |\n| `--models` | 模型名称，支持多个模型用逗号分割\u003cbr/\u003e如：`gpt-4,claude-3-sonnet` | - | ✅ |\n| `--concurrency` | 并发数 | `3` | ❌ |\n| `--count` | 请求总数 | `10` | ❌ |\n| `--timeout` | 请求超时时间（秒） | `300` | ❌ |\n| `--prompt` | 测试提示语（直接输入字符串）\u003cbr/\u003e如：`\"分析人工智能的发展前景\"` | `\"你好，介绍一下你自己。\"` | ❌ |\n| `--prompt-file` | 从文件读取 prompt\u003cbr/\u003e**支持多种模式**：\u003cbr/\u003e• 单文件：`\"prompts/test.txt\"`\u003cbr/\u003e• 通配符：`\"prompts/*.txt\"`\u003cbr/\u003e• 相对/绝对路径均可 | - | ❌ |\n| `--prompt-length` | 生成指定字符长度的测试 prompt\u003cbr/\u003e**快速测试功能**：无需准备文件即可生成测试内容\u003cbr/\u003e• 优先级高于其他 prompt 参数\u003cbr/\u003e• 生成有意义的中文文本片段 | `0`（不启用） | ❌ |\n| `--stream` | 是否开启流模式 | `true` | ❌ |\n| `--thinking` | 是否开启思考模式（仅 OpenAI 协议支持） | `false` | ❌ |\n| `--log` | 是否开启详细日志记录 | `false` | ❌ |\n| `--report` | 是否生成报告文件（同时生成 JSON 和 CSV） | `false` | ❌ |\n\n**注意**：\n\n- `--model` 和 `--models` 不能同时使用。使用 `--model` 测试单个模型，使用 `--models` 测试多个模型\n- prompt 参数优先级：`--prompt-length` \u003e `--prompt-file` \u003e `--prompt` \u003e 管道输入 \u003e 默认值\n\n## 📊 输出指标说明\n\n### 终端输出指标\n\n- **TTFT (Time To First Token)**: 首字节时间，衡量模型开始响应的速度\n- **TPOT (Time Per Output Token)**: 每个输出 token 的平均耗时（除首 token 外），衡量生成速度的稳定性\n- **输出 TPS (Tokens Per Second)**: 每秒输出的 token 数，基于输出 tokens 计算\n- **吞吐 TPS (Total Throughput TPS)**: 每秒处理的总 token 数，基于输入+输出 tokens 计算，衡量系统整体吞吐量\n- **平均/最小/最大/标准差响应时间**: 请求的响应时间统计，标准差（以 ±n 格式显示）反映性能稳定性\n- **网络性能指标**: DNS 解析、TCP 连接、TLS 握手时间\n- **思考 Token 数**: 模型思考过程使用的 token 数（仅在 `--thinking` 模式下显示）\n\n### 单模型详细报告示例\n\n```text\n┌──────────────────┬──────────┬──────────┬──────────┬──────────┬────────┬────────────────────────────┐\n│      指标        │  最小值  │  平均值  │  标准差  │  最大值  │  单位  │      采样方式说明          │\n├──────────────────┼──────────┼──────────┼──────────┼──────────┼────────┼────────────────────────────┤\n│ 🕐 总耗时        │  2.45s   │  2.89s   │  ±0.12s  │  3.15s   │  时间  │ 请求发起到完全结束的时间   │\n│ ⚡ TTFT          │  0.85s   │  0.92s   │  ±0.05s  │  1.02s   │  时间  │ 首个 token 响应时间        │\n│ 🚀 输出 TPS      │  45.23   │  52.18   │  ±3.21   │  58.96   │  个/秒 │ 输出 tokens / 总耗时       │\n│ 🌐 吞吐 TPS      │  123.45  │  145.67  │  ±8.92   │  165.43  │  个/秒 │ (输入+输出) / 总耗时       │\n└──────────────────┴──────────┴──────────┴──────────┴──────────┴────────┴────────────────────────────┘\n```\n\n### 多模型对比报告示例\n\n```text\n┌────────────────┬──────────┬────────┬──────────┬────────────┬─────────────┬────────────────┬────────────────┬──────────────────┐\n│    🤖 模型     │ 📊 请求数│ ⚡ 并发│ ✅ 成功率│ 🕐 平均总耗时│ ⚡ 平均 TTFT │ 🚀 平均输出 TPS│ 🌐 平均吞吐 TPS│ 🎲 平均输出Token数│\n├────────────────┼──────────┼────────┼──────────┼────────────┼─────────────┼────────────────┼────────────────┼──────────────────┤\n│ gpt-4          │    10    │   3    │  100.00% │   2.89s    │    0.92s    │     52.18      │     145.67     │       150        │\n│ claude-3-sonnet│    10    │   3    │  100.00% │   2.34s    │    0.78s    │     58.42      │     156.23     │       137        │\n└────────────────┴──────────┴────────┴──────────┴────────────┴─────────────┴────────────────┴────────────────┴──────────────────┘\n```\n\n### 报告文件生成\n\n当使用 `--report` 参数时，将在当前目录生成多种格式的报告文件：\n\n#### 单模型测试\n\n- **JSON 报告**: `ait-report-{模型名}-{时间戳}.json` - 详细的结构化数据\n- **CSV 报告**: `ait-report-{模型名}-{时间戳}.csv` - 表格格式，便于导入 Excel 分析\n\n#### 多模型测试\n\n- **每个模型的独立报告**: JSON 和 CSV 格式各一份\n- **综合比较报告**: `ait-comparison-{时间戳}.csv` - 包含所有模型的比较数据\n\n#### 报告内容包含\n\n**JSON 报告文件结构:**\n\n- **metadata**: 测试元数据（时间戳、协议、模型名称、配置信息等）\n- **time_metrics**: 时间性能指标（平均、最小、最大、标准差响应时间）\n- **network_metrics**: 网络性能指标（DNS、TCP连接、TLS握手时间，目标IP）\n- **content_metrics**: 服务性能指标（TTFT、TPOT、Token统计、输出TPS、吞吐TPS等）\n- **reliability_metrics**: 可靠性指标（成功率、错误率）\n- **variance_metrics**: 方差指标（总耗时、TTFT、TPOT、Token数、TPS的标准差，用于评估性能稳定性）\n\n**CSV 报告文件格式:**\n\n- 扁平化的数据结构，便于导入 Excel 或其他数据分析工具\n- 包含所有性能指标的数值化数据\n- 支持多模型对比分析和图表生成\n\n**多模型报告特性:**\n\n- 每个模型生成独立的 JSON 和 CSV 报告\n- 额外生成综合对比 CSV 文件，包含所有模型的关键指标\n- 文件命名格式：`ait-report-{timestamp}.{format}` 或 `ait-report-{model}-{timestamp}.{format}`\n\n## 🎯 使用场景\n\n- **模型性能基准测试**: 评估不同模型的响应速度和质量\n- **多模型比较测试**: 同时测试多个模型并生成比较报告\n- **服务压力测试**: 测试服务在不同并发下的表现\n- **API 接口验证**: 验证 OpenAI 兼容接口的正确性\n- **性能监控**: 定期监控模型服务的性能表现\n- **容量规划**: 为生产环境部署提供性能数据支持\n- **自动化测试**: 结合 CI/CD 流程进行自动化性能测试\n- **性能报告**: 生成详细的 JSON 和 CSV 报告用于数据分析和存档\n\n## 📝 使用示例\n\n### Prompt 输入方式演示\n\n```bash\n# 1. 快速生成指定长度的测试内容（推荐用于快速测试）\nait --models=gpt-4 --prompt-length=500 --count=5 --report\n\n# 2. 直接字符串\nait --models=gpt-4 --prompt=\"分析人工智能的发展前景\" --count=5\n\n# 3. 单个文件\necho \"请解释机器学习的基本概念和应用场景\" \u003e ml_prompt.txt\nait --models=claude-3-sonnet --prompt-file=ml_prompt.txt --count=3\n\n# 4. 多文件通配符（随机选择）\nmkdir test_prompts\necho \"分析深度学习的优缺点\" \u003e test_prompts/dl.txt\necho \"比较不同 NLP 模型的特点\" \u003e test_prompts/nlp.txt\necho \"解释计算机视觉的应用\" \u003e test_prompts/cv.txt\nait --models=gpt-4,claude-3-sonnet --prompt-file=\"test_prompts/*.txt\" --count=10 --report\n\n# 5. 管道输入（未使用其他 prompt 参数时生效）\necho \"请分析以下代码的性能\" | ait --models=gpt-3.5-turbo --count=2\n\n# 6. 复杂多行 prompt 通过管道输入\ncat \u003c\u003c 'EOF' | ait --models=gpt-4 --count=1 --report\n请作为一个资深软件架构师，分析以下系统设计：\n\n1. 微服务架构的优势和挑战\n2. 数据一致性解决方案\n3. 服务间通信最佳实践\n4. 性能优化建议\n\n请提供详细的分析和具体的解决方案。\nEOF\n```\n\n### 不同长度输入性能测试\n\n```bash\n# 测试短输入（100字符）\nait --models=gpt-4 --prompt-length=100 --count=10 --report\n\n# 测试中等长度输入（500字符）\nait --models=gpt-4 --prompt-length=500 --count=10 --report\n\n# 测试长输入（2000字符）\nait --models=gpt-4 --prompt-length=2000 --count=10 --report\n\n# 对比不同模型处理长输入的能力\nait --models=gpt-4,claude-3-sonnet,gemini-2.0-flash --prompt-length=1500 --count=20 --concurrency=5 --report\n```\n\n### 最新模型测试\n\n```bash\n# 测试最新的 Claude 4.x 系列模型\nait --models=claude-4.1-opus,claude-4.0-sonnet,claude-4.0-opus --count=5 --report\n\n# 测试最新的 Gemini 2.x 系列模型\nait --models=gemini-2.5-pro,gemini-2.5-flash,gemini-2.0-flash --count=5 --report\n\n# 测试 Claude 3.x 系列模型\nait --models=claude-3.7-sonnet,claude-3.5-haiku --count=5 --report\n```\n\n## 🧰 Prompt 生成助手 tpg\n\n`tpg`（Test Prompt Generator）是随项目提供的辅助工具，用于批量生成高质量、语言多样的 Prompt 文件，搭配 `ait` 做大规模压测尤为省心。\n\n- 🧠 **内置多语言语料**：覆盖中英文及多语种，轻松模拟全球业务场景\n- 📄 **文本文件输出**：生成 `.txt` 格式的 prompt 文件，便于集成各种测试流程\n- 🧩 **模板占位符**：`{{content}}`、`{{index}}`、`{{timestamp}}` 等，方便拼装上下文\n\n### 安装 tpg\n\n#### tpg Linux/macOS 一键安装脚本\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/yinxulai/ait/main/scripts/install-tpg.sh | bash\n```\n\n\u003e 脚本会自动识别操作系统（Linux/macOS）和架构（`x86_64`, `aarch64`, `armv7l`, `i386`），下载最新版本并安装到 `/usr/local/bin`。如需自定义安装目录，可先下载脚本再执行：`curl -fsSL https://raw.githubusercontent.com/yinxulai/ait/main/scripts/install-tpg.sh -o install-tpg.sh \u0026\u0026 INSTALL_DIR=$HOME/.local/bin bash install-tpg.sh`。\n\n#### 手动下载安装\n\n从 [Releases 页面](https://github.com/yinxulai/ait/releases) 下载适合您平台的 tpg 二进制文件：\n\n```bash\n# Linux (x64)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-linux-amd64\nchmod +x tpg-linux-amd64\nsudo mv tpg-linux-amd64 /usr/local/bin/tpg\n\n# Linux (ARM64)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-linux-arm64\nchmod +x tpg-linux-arm64\nsudo mv tpg-linux-arm64 /usr/local/bin/tpg\n\n# Linux (ARM)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-linux-arm\nchmod +x tpg-linux-arm\nsudo mv tpg-linux-arm /usr/local/bin/tpg\n\n# Linux (386)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-linux-386\nchmod +x tpg-linux-386\nsudo mv tpg-linux-386 /usr/local/bin/tpg\n\n# macOS (Intel)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-darwin-amd64\nchmod +x tpg-darwin-amd64\nsudo mv tpg-darwin-amd64 /usr/local/bin/tpg\n\n# macOS (Apple Silicon)\nwget https://github.com/yinxulai/ait/releases/latest/download/tpg-darwin-arm64\nchmod +x tpg-darwin-arm64\nsudo mv tpg-darwin-arm64 /usr/local/bin/tpg\n\n# Windows (x64) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/tpg-windows-amd64.exe\" -OutFile \"tpg.exe\"\n# 将 tpg.exe 移动到您的 PATH 中\n\n# Windows (ARM64) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/tpg-windows-arm64.exe\" -OutFile \"tpg.exe\"\n# 将 tpg.exe 移动到您的 PATH 中\n\n# Windows (386) - PowerShell\nInvoke-WebRequest -Uri \"https://github.com/yinxulai/ait/releases/latest/download/tpg-windows-386.exe\" -OutFile \"tpg.exe\"\n# 将 tpg.exe 移动到您的 PATH 中\n```\n\n#### 从源码编译\n\n```bash\n# 克隆项目\ngit clone https://github.com/yinxulai/ait.git\ncd ait\n\n# 编译 tpg\nmake build\n\n# 或者直接用 go build\ngo build -o bin/tpg ./cmd/tpg/\n```\n\n### tpg 使用示例\n\n```bash\n# 生成 100 条 500 字左右的 Prompt，并按照模板写入 prompts/think\ntpg \\\n  -count=100 \\\n  -length=500 \\\n  -output=prompts/think \\\n  -template=\"帮我生成 400 词左右的内容摘要: {{content}}\"\n\n# 搭配 ait 做批量压测\nait \\\n  --models=deepseek-v3-1-terminus,gemini-2.5-pro \\\n  --prompt-file=\"prompts/think/*.txt\" \\\n  --count=500 \\\n  --concurrency=50 \\\n  --report\n```\n\n### tpg 参数说明\n\n| 参数 | 描述 | 默认值 |\n| :--- | :--- | :--- |\n| `-count` | 生成的 prompt 数量 | `10` |\n| `-length` | 每个 prompt 的近似长度（字符数） | `50` |\n| `-output` | 输出目录 | `prompts` |\n| `-template` | 模板字符串，支持占位符 | 无 |\n| `-help` | 显示帮助信息 | - |\n\n### 模板占位符\n\n- `{{content}}` - 生成的 prompt 内容\n- `{{index}}` - prompt 序号（从 1 开始）  \n- `{{timestamp}}` - 当前时间戳（RFC3339 格式）\n\n\u003e 更多详细用法可运行 `tpg -help` 查看。\n\n## 🔧 开发和贡献\n\n### 可用命令\n\n```bash\nmake build                    # 编译二进制文件（默认版本 dev）\nmake build VERSION=v1.0.0     # 指定版本号编译\nmake test                     # 运行测试\nmake clean                    # 清理构建文件\nmake tidy                     # 格式化代码并整理模块依赖\nmake help                     # 查看所有命令\n```\n\n### 版本信息注入\n\n构建时可通过 `VERSION` 变量指定版本号：\n\n```bash\n# 本地构建\nmake build VERSION=v1.0.0\n\n# 查看版本\n./bin/ait --version\n# 输出：\n# ait version v1.0.0\n# Git Commit: 5ad79fb\n# Build Time: 2025-12-08_10:30:15\n```\n\n### 测试覆盖率\n\n项目已集成 codecov 测试覆盖率上报，每次 push 和 pull request 都会自动运行测试并上报覆盖率数据。\n\n## 📄 许可证\n\nMIT License\n\n## 🤝 贡献\n\n欢迎提交 Issue 和 Pull Request！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinxulai%2Fait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyinxulai%2Fait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinxulai%2Fait/lists"}