DEV Community

Alex Chen
Alex Chen

Posted on

Quick Tip: Benchmark AI Model Speeds in Under 10 Minutes

Hey there! Let me show you something I've been obsessing over lately — and trust me, it's made a huge difference in how I build AI-powered apps.

You know that feeling when you're chatting with an AI, and it takes forever to start responding? That awkward pause where you're just staring at the screen, wondering if it crashed? Yeah, I've been there too. And as someone who builds with these APIs daily, I've learned that speed isn't just a nice-to-have — it's the difference between users loving your app or closing the tab forever.

Here's the thing: every 100 milliseconds of delay can cost you users. When I first started integrating AI into my projects, I just picked the most popular model and hoped for the best. Big mistake. What I didn't realise is that the "fastest" model on paper might actually be a slowpoke in practice.

So let's dive into what I found after spending a weekend benchmarking 15 different AI models. I'll show you exactly how I tested them, what surprised me, and how you can avoid the same mistakes I made.

Why Speed Matters More Than You Think

Before we jump into the numbers, let me share a quick story. Last month, I was building a customer support chatbot for a friend's e-commerce site. I used a well-known premium model because I thought "bigger = better." The responses were great quality-wise, but users kept complaining that the bot was "thinking too long."

Turns out, that model had an 800ms Time to First Token (TTFT). In chat terms, that's an eternity. Users would type their question, wait… wait… and then refresh the page thinking it broke.

I switched to a faster model with 180ms TTFT, and suddenly users were happy. Same task, same quality, but the experience felt completely different.

This is why benchmarking matters. Let me walk you through my setup.

My Testing Setup

I wanted this to be practical — something you could replicate in five minutes. Here's what I used:

Setting What I Did
When May 20, 2026
Where US East (Ohio) and Asia (Singapore)
Prompt "Explain recursion in 200 words"
Output length ~150 tokens per run
How many runs 10 per model, averaged
Streaming Yes (Server-Sent Events)
API endpoint https://global-apis.com/v1

The key insight? I tested from two geographic regions. Because what's fast in New York might be sluggish in Tokyo.

The Speed Champions (Ranked)

Alright, here's what I found. I'm ranking these by tokens per second — think of this as "how fast does the model actually type."

Rank Model TTFT (ms) Tokens/sec Cost per Million Output Tokens
🥇 Step-3.5-Flash 120 80 $0.15
🥈 DeepSeek V4 Flash 180 60 $0.25
🥉 Hunyuan-TurboS 200 55 $0.28
4 Qwen3-8B 150 70 $0.01
5 Qwen3-32B 250 45 $0.28
6 Doubao-Seed-Lite 220 50 $0.40
7 Hunyuan-Turbo 280 42 $0.57
8 GLM-4-32B 300 38 $0.56
9 Qwen3.5-27B 350 35 $0.19
10 DeepSeek V4 Pro 400 30 $0.78
11 MiniMax M2.5 450 28 $1.15
12 GLM-5 500 25 $1.92
13 Kimi K2.5 600 20 $3.00
14 DeepSeek-R1 800 15 $2.50
15 Qwen3.5-397B 1200 10 $2.34

One thing I should mention: models like DeepSeek-R1 and Kimi K2.5 are "reasoning" models — they literally think before they speak. That internal thinking time counts toward the TTFT number. So don't write them off completely; they're just built for different use cases.

Let's Write Some Code

Enough theory — let me show you how to test this yourself. Here's a Python script I use to measure TTFT and tokens per second:

import time
import requests
import json

def benchmark_model(model_name, api_key):
    """
    Simple benchmark to measure TTFT and tokens/second
    """
    url = "https://global-apis.com/v1/chat/completions"

    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }

    payload = {
        "model": model_name,
        "messages": [
            {"role": "user", "content": "Explain recursion in 200 words"}
        ],
        "stream": True,
        "max_tokens": 200
    }

    # Start the clock
    start_time = time.time()
    first_token_time = None
    total_tokens = 0

    # Send request with streaming
    response = requests.post(url, headers=headers, json=payload, stream=True)

    for line in response.iter_lines():
        if line:
            # Skip the "data: [DONE]" message
            if line.decode('utf-8').strip() == 'data: [DONE]':
                break

            # Remove "data: " prefix
            if line.decode('utf-8').startswith('data: '):
                json_str = line.decode('utf-8')[6:]
                try:
                    chunk = json.loads(json_str)
                    if 'choices' in chunk and len(chunk['choices']) > 0:
                        delta = chunk['choices'][0].get('delta', {})
                        if 'content' in delta and delta['content']:
                            # First token received
                            if first_token_time is None:
                                first_token_time = time.time()
                            total_tokens += 1
                except:
                    pass

    end_time = time.time()

    # Calculate metrics
    ttft = (first_token_time - start_time) * 1000 if first_token_time else 0
    total_time = end_time - start_time
    tokens_per_second = total_tokens / total_time if total_time > 0 else 0

    return {
        "model": model_name,
        "ttft_ms": round(ttft, 0),
        "tokens_per_second": round(tokens_per_second, 1),
        "total_tokens": total_tokens
    }

# Example usage
results = benchmark_model("deepseek-v4-flash", "your-api-key-here")
print(f"Model: {results['model']}")
print(f"TTFT: {results['ttft_ms']}ms")
print(f"Speed: {results['tokens_per_second']} tok/s")
Enter fullscreen mode Exit fullscreen mode

And here's a simpler version if you want to test multiple models in a loop:

import asyncio
from openai import AsyncOpenAI

async def test_model_speed(client, model_name):
    """
    Async version using OpenAI-compatible client
    """
    start = asyncio.get_event_loop().time()

    response = await client.chat.completions.create(
        model=model_name,
        messages=[{"role": "user", "content": "Tell me a joke"}],
        stream=True,
        max_tokens=50
    )

    first_token = None
    token_count = 0

    async for chunk in response:
        if chunk.choices[0].delta.content:
            if first_token is None:
                first_token = asyncio.get_event_loop().time()
            token_count += 1

    end = asyncio.get_event_loop().time()

    ttft = (first_token - start) * 1000
    speed = token_count / (end - start)

    return {"model": model_name, "ttft": ttft, "tokens_per_sec": speed}

# Usage
client = AsyncOpenAI(
    base_url="https://global-apis.com/v1",
    api_key="your-key"
)

models_to_test = [
    "step-3.5-flash",
    "deepseek-v4-flash",
    "hunyuan-turbos"
]

async def run_benchmarks():
    for model in models_to_test:
        result = await test_model_speed(client, model)
        print(f"{result['model']}: {result['ttft']:.0f}ms TTFT, {result['tokens_per_sec']:.1f} tok/s")

# Run it
asyncio.run(run_benchmarks())
Enter fullscreen mode Exit fullscreen mode

Breaking Down the Results by Budget

Let me help you make sense of these numbers based on what you're willing to spend.

Ultra-Budget (Under $0.15 per million output tokens)

Model Speed Cost
Qwen3-8B 70 tok/s $0.01/M
Step-3.5-Flash 80 tok/s $0.15/M

I honestly couldn't believe Qwen3-8B when I first tested it. Seventy tokens per second for one cent per million tokens? That's practically free. For simple tasks like autocomplete, categorization, or basic Q&A where you don't need deep reasoning, this is your go-to.

Budget Sweet Spot ($0.15 – $0.30 per million)

Model Speed Cost
DeepSeek V4 Flash 60 tok/s $0.25/M
Hunyuan-TurboS 55 tok/s $0.28/M
Qwen3-32B 45 tok/s $0.28/M

This is where I spend most of my time. DeepSeek V4 Flash gives you GPT-4-class quality at a fraction of the cost and speed that rivals much smaller models. For my customer support bot, this was the winner — fast enough that users feel it's instant, smart enough to handle complex questions.

Mid-Range ($0.30 – $0.80 per million)

Model Speed Cost
Doubao-Seed-Lite 50 tok/s $0.40/M
GLM-4-32B 38 tok/s $0.56/M
Hunyuan-Turbo 42 tok/s $0.57/M
DeepSeek V4 Pro 30 tok/s $0.78/M

These are the workhorses. They're slower because they're bigger and more thoughtful. DeepSeek V4 Pro at 30 tok/s might seem slow compared to Flash's 60 tok/s, but the quality difference is noticeable for tasks requiring careful analysis.

Premium (Over $0.80 per million)

Model Speed Cost
MiniMax M2.5 28 tok/s $1.15/M
GLM-5 25 tok/s $1.92/M
Kimi K2.5 20 tok/s $3.00/M

These are for when correctness trumps everything else. If you're building a medical diagnosis tool or legal document analyzer, you want quality over speed. Just be prepared for that 600ms wait before the first token arrives.

Geography Matters More Than You'd Think

Here's something that surprised me. I ran the same tests from US East and Asia, and the differences were significant:

Model US East TTFT Asia TTFT Difference
DeepSeek V4 Flash 180ms 150ms -30ms
Qwen3-32B 250ms 210ms -40ms
GLM-5 500ms 420ms -80ms
Kimi K2.5 600ms 480ms -120ms

Chinese models like Qwen, GLM, and Kimi are 16-20% faster when accessed from Asia because their servers are closer. DeepSeek seems to have good global distribution, so it's consistent everywhere.

If your users are mainly in Asia, you might want to prioritize Asian models. If your users are global, DeepSeek V4 Flash is probably your best bet for consistent performance.

Real Talk: What This Means for Your App

Let me give you a practical framework I use now when choosing models for chat applications:

TTFT Range User Experience My Recommendation
Under 200ms "Instant" — users are happy Use for primary chat
200-400ms "Fast" — acceptable Use for secondary features
400-800ms "Noticeable delay" — some users frustrated Only for background tasks
Over 800ms "Slow" — users leave Avoid for interactive use

For my main chatbot, I aim for TTFT under 400ms. That means DeepSeek V4 Flash (180ms), Qwen3-8B (150ms), or Step-3.5-Flash (120ms) are my go-to choices.

My Personal Recommendations

After all this testing, here's what I'd tell you:

For a general-purpose chatbot: Start with DeepSeek V4 Flash. Great balance of speed (60 tok/s), quality, and cost ($0.25/M). It's my daily driver.

For simple tasks at scale: Qwen3-8B at $0.01/M and 70 tok/s is absurdly cheap. Use it for categorization, simple Q&A, or autocomplete.

For complex reasoning: DeepSeek V4 Pro or GLM-5. Yes, they're slower, but when accuracy matters, speed is secondary.

For Asian users: Consider Qwen3-32B or Hunyuan-TurboS. They'll feel faster due to geographic proximity.

One More Thing

I want to mention something that made my testing much easier. Instead of signing up for a dozen different API providers and managing multiple accounts, I found that Global API (https://global-apis.com/v1) gives you access to all these models through a single endpoint. Same API format, one key, consistent billing.

That's actually how I ran these benchmarks — one script, one API key, 15 models. It saved me hours of setup time.

If you're tired of managing multiple API integrations and just want to test which model works best for your use case, it's worth checking out. No affiliate nonsense here — it's just genuinely useful.

Wrapping Up

Speed benchmarking isn't just a fun science experiment — it directly impacts your users' experience and your bottom line. The difference between a 150ms TTFT and a 600ms TTFT can mean the difference between users loving your app or rage-quitting.

My advice? Don't just pick the most popular model. Test it yourself. Run the code I showed you above, swap in your own prompts, and see what works for your specific use case. The numbers in this post are a great starting point, but your mileage may vary based on your users' locations and your specific tasks.

And hey, if you want to skip the setup hassle, Global API has all these models ready to go at https://global-apis.com/v1. Just grab a key and start benchmarking. Your users will thank you.

Happy coding, and may your TTFT be ever under 200ms!

Top comments (0)