📊 We use cookies & analytics to improve your experience. Learn more
Latest

Software Testing — Manual and Automation Module 4 · Lesson 12 of 15

0% Exit to course

Module 4 · Testing behind the screen Lesson 12 of 15

A performance smoke test

Learning objective

A performance test answers one question: does the page still answer in a reasonable time when several people use it at once. You do not need a load-testing platform to find the obvious slow case.

The concept

Start with the endpoint that already feels slow to you, at the load you actually expect, and compare against a number you chose in advance - not against a feeling after the fact.

The bug you are hunting is the one that grows with data: a missing index, an N-plus-one query, an unbounded list. A smoke test catches those; a full load test is for later.

Python
import statistics, time, requests

def test_search_is_fast_enough():
    times = []
    for _ in range(50):
        t0 = time.perf_counter()
        requests.get("http://localhost:3000/api/jobs?q=analyst", timeout=10)
        times.append(time.perf_counter() - t0)
    median = statistics.median(times)
    assert median < 1.0, f"median {median:.2f}s"
    print(f"median {median:.3f}s  worst {max(times):.3f}s")

Worked example

Time fifty requests to the search endpoint and assert the median under one second; that catches the query that was fine with ten rows and dies with ten thousand.

Your practice task

Measure the response time of one endpoint under a repeated call and write down the median and the worst case.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

Start with the endpoint that already feels slow to you, at the load you actually expect, and compare against a number you chose in advance - not against a feeling after the fact.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.

Next recommended course Full-Stack Web Development Bootcamp