LLM API 性能测试工具使用指南

目录
文章提供了 Linux 和 Windows 平台上的快速开始指南,包括下载、配置和运行工具的命令示例。
本工具是用作测试 LLM API 性能,包括预填充速度、解码速度、首字延迟、延迟等。目前代码已经开源在github上,本篇主要介绍该工具如何使用。
项目地址: https://github.com/Yoosu-L/llmapibenchmark
🚀 快速开始
🐧 Linux
下载并解压
wget https://github.com/Yoosu-L/llmapibenchmark/releases/latest/download/llmapibenchmark_linux_amd64.tar.gz
tar -zxvf llmapibenchmark_linux_amd64.tar.gz
注意
下面这条命令主要测试总解码速度(生成吞吐)可达到的最大值,适用于短输入、长输出的场景,并发数默认从1到128。
将 base_url 替换为你的 api 服务 url,以v1结尾。
./llmapibenchmark_linux_amd64 --base-url https://your-api-endpoint.com/v1
注意
测试总预填充速度的最大值,适用于长输入、长输出的场景,可适当改变 num-words 以及 concurrency level。
将 base_url 替换为你的 api 服务 url,以v1结尾。
./llmapibenchmark_linux_amd64 --base-url https://your-api-endpoint.com/v1 --num-words 6000 --concurrency 1,2,4,8,16,32
🪟 Windows
解压后得到 llmapibenchmark_windows_amd64.exe
注意
下面这条命令主要测试总解码速度(生成吞吐)可达到的最大值,适用于短输入、长输出的场景,并发数默认从1到128。
将 base_url 替换为你的 api 服务 url,以v1结尾。
llmapibenchmark_windows_amd64.exe --base-url https://your-api-endpoint.com/v1
注意
测试总预填充速度的最大值,适用于长输入、长输出的场景,可适当改变 num-words 以及 concurrency level。
将 base_url 替换为你的 api 服务 url,以v1结尾。
llmapibenchmark_windows_amd64.exe --base-url https://your-api-endpoint.com/v1 --num-words 6000 --concurrency 1,2,4,8,16,32
📊 示例输出
⌨️ 终端实时输出
################################################################################################################
LLM API Throughput Benchmark
https://github.com/Yoosu-L/llmapibenchmark
Time:2024-12-03 03:11:48 UTC+0
################################################################################################################
Input Tokens: 45
Output Tokens: 512
Test Model: qwen2.5:0.5b
Latency: 0.00 ms
| Concurrency | Generation Throughput (tokens/s) | Prompt Throughput (tokens/s) | Min TTFT (s) | Max TTFT (s) |
|-------------|----------------------------------|-------------------------------|--------------|--------------|
| 1 | 31.88 | 976.60 | 0.05 | 0.05 |
| 2 | 30.57 | 565.40 | 0.07 | 0.16 |
| 4 | 31.00 | 717.96 | 0.11 | 0.25 |
📄 md文件
Input Tokens: 45
Output Tokens: 512
Test Model: Qwen2.5-7B-Instruct-AWQ
Latency: 2.20 ms
| Concurrency | Generation Throughput (tokens/s) | Prompt Throughput (tokens/s) | Min TTFT (s) | Max TTFT (s) |
|---|---|---|---|---|
| 1 | 58.49 | 846.81 | 0.05 | 0.05 |
| 2 | 114.09 | 989.94 | 0.08 | 0.09 |
| 4 | 222.62 | 1193.99 | 0.11 | 0.15 |
| 8 | 414.35 | 1479.76 | 0.11 | 0.24 |
| 16 | 752.26 | 1543.29 | 0.13 | 0.47 |
| 32 | 653.94 | 1625.07 | 0.14 | 0.89 |
📝 Json (enable with --format json)
{
"model_name": "Qwen2.5-7B-Instruct-AWQ",
"input_tokens": 32,
"output_tokens": 512,
"latency": 1,
"results": [
{
"concurrency": 1,
"generation_speed": 118.18,
"prompt_throughput": 42.69,
"max_ttft": 0.61,
"min_ttft": 0.61
},
{
"concurrency": 2,
"generation_speed": 214.37,
"prompt_throughput": 48.64,
"max_ttft": 1.07,
"min_ttft": 0.42
}
]
}
🗒️ Yaml (enable with --format yaml)
model-name: Qwen2.5-7B-Instruct-AWQ
input-tokens: 32
output-tokens: 512
latency: 1.6
results:
- concurrency: 1
generation-speed: 134.28
prompt-throughput: 59.31
max-ttft: 0.44
min-ttft: 0.44
- concurrency: 2
generation-speed: 221.23
prompt-throughput: 51.06
max-ttft: 1.02
min-ttft: 0.47
⚙️ 进阶参数
Linux:
./llmapibenchmark_linux_amd64 \
--base-url https://your-api-endpoint.com/v1 \
--api-key YOUR_API_KEY \
--model gpt-3.5-turbo \
--concurrency 1,2,4,8,16 \
--max-tokens 512 \
--num-words 513 \
--prompt "Your custom prompt here" \
--format json
Windows:
llmapibenchmark_windows_amd64.exe ^
--base-url https://your-api-endpoint.com/v1 ^
--api-key YOUR_API_KEY ^
--model gpt-3.5-turbo ^
--concurrency 1,2,4,8,16 ^
--max-tokens 512 ^
--num-words 513 ^
--prompt "Your custom prompt here" ^
--format json
📋 参数解析
| Parameter | Short | Description | Default | Required |
|---|---|---|---|---|
--base-url | -u | Base URL for LLM API endpoint | Empty (MUST be specified) | Yes |
--api-key | -k | API authentication key | None | No |
--model | -m | Specific AI model to test | Automatically discovers first available model | No |
--concurrency | -c | Comma-separated concurrency levels to test | 1,2,4,8,16,32,64,128 | No |
--max-tokens | -t | Maximum tokens to generate per request | 512 | No |
--num-words | -n | Number of words for random input prompt | 0 | No |
--prompt | -p | Text prompt for generating responses | A long story | No |
--format | -f | Output format (json, yaml) | "" | No |
--help | -h | Show help message | false | No |