---
title: "How k6 runs your test script | Grafana Labs"
description: "How k6 executes tests with virtual users and iterations, and the three parts of a k6 script"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

## How k6 runs your test

**Virtual users** (VUs) run your `default` function in parallel loops without shared variables. One **iteration** is one full run of `default` by one VU. **Duration** or **stages** decide how long VUs keep looping.

## Three parts of a k6 script

A k6 script has up to three parts. In the first learning path, you only use `options` and the `default` function.

### Minimal example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
export const options = {
  vus: 10,
  duration: '30s',
  thresholds: {
    http_req_duration: ['p(95)<500'],
  },
};

export default function () {
  http.get('https://quickpizza.grafana.com');
  sleep(1);
}
```

- **`options`** — how hard you push, for how long, and what pass or fail means for the run.
- **`default`** — what each virtual user does each iteration: requests and checks.
- **`setup` / `teardown`** *(optional)* — one-time shared prep and cleanup, for tokens or test data. Refer to [Test lifecycle](/docs/k6/latest/using-k6/test-lifecycle/) when a later script needs them.
