You can write this as
```
for (tasks <- stageToTaskActive.values; t <- tasks) {
  activeTime += t.timeRunning(System.currentTimeMillis())
}
```

Actually, to make it better, you should also grab `System.currentTimeMillis()` just once at the top (e.g. `val now = System.currentTimeMillis()`) instead of calling it repeatedly there.