> For the complete documentation index, see [llms.txt](https://richardweiyang-2.gitbook.io/systemtap_with_examples/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://richardweiyang-2.gitbook.io/systemtap_with_examples/example/duration.md).

# Duration

Here is an example to measure duration of a function call.

```
global time
probe vfs.read
{
    time[tid()] = gettimeofday_ns();
}
probe vfs.read.return
{
    if(time[tid()]) {
        printf("vfs.read by %s took %d ns to execute\n",
            execname(), gettimeofday_ns() - time[tid()]);
        delete time[tid()];
        exit();
    }
}
```
