0
0
Testing Fundamentalstesting~6 mins

Performance metrics (response time, throughput) in Testing Fundamentals - Full Explanation

Choose your learning style9 modes available
Introduction
Imagine using a website that takes forever to load or a service that can only handle a few users at a time. These problems happen because of performance issues. To understand and fix these, we use performance metrics that measure how fast and how much a system can handle.
Explanation
Response Time
Response time measures how long it takes for a system to react to a request. It starts when a user sends a request and ends when the system finishes processing and sends back a result. This metric helps us know how quickly users get feedback from the system.
Response time shows how fast a system responds to a single request.
Throughput
Throughput measures how many requests a system can handle in a given time, usually per second or minute. It tells us about the system's capacity to process multiple requests efficiently. Higher throughput means the system can serve more users or tasks at once.
Throughput indicates the volume of work a system can process over time.
Real World Analogy

Think of a coffee shop where customers place orders. Response time is like how long a customer waits from ordering to receiving their coffee. Throughput is how many customers the shop can serve in an hour.

Response Time → Time a customer waits for their coffee after ordering
Throughput → Number of customers served by the coffee shop in one hour
Diagram
Diagram
┌───────────────┐       ┌───────────────┐
│ User Request  │──────▶│ System        │
│ (Start Timer) │       │ Processes Req │
└───────────────┘       └───────────────┘
         │                       │
         │                       │
         │                       ▼
         │               ┌───────────────┐
         │               │ Response Sent │
         │               │ (Stop Timer)  │
         │               └───────────────┘
         ▼
  Response Time

Throughput: Number of requests processed per unit time (e.g., per second)
This diagram shows the flow of a user request through the system to measure response time and how throughput counts requests over time.
Key Facts
Response TimeThe duration between sending a request and receiving a response from the system.
ThroughputThe number of requests a system can process in a given time period.
Low Response TimeMeans the system responds quickly to individual requests.
High ThroughputMeans the system can handle many requests efficiently.
Code Example
Testing Fundamentals
import time

# Simulate processing a request
start_time = time.perf_counter()
time.sleep(0.2)  # Simulate work taking 0.2 seconds
end_time = time.perf_counter()

response_time = end_time - start_time
print(f"Response time: {response_time:.3f} seconds")

# Simulate throughput calculation
requests_processed = 50
total_time_seconds = 10
throughput = requests_processed / total_time_seconds
print(f"Throughput: {throughput} requests per second")
OutputSuccess
Common Confusions
Response time and throughput are the same.
Response time and throughput are the same. Response time measures speed for one request, while throughput measures how many requests are handled over time.
A system with high throughput always has low response time.
A system with high throughput always has low response time. A system can handle many requests (high throughput) but still respond slowly to each one (high response time) if overloaded.
Summary
Response time measures how quickly a system answers a single request.
Throughput measures how many requests a system can handle in a set time.
Both metrics help understand and improve system performance but focus on different aspects.