# Function veloren_common_ecs::gen_stats

source · ```
pub fn gen_stats(
timelines: &HashMap<String, CpuTimeline>,
tick_work_start: Instant,
rayon_threads: u32,
physical_threads: u32,
) -> HashMap<String, CpuTimeStats>
```

## Expand description

The Idea is to transform individual timelines per system to a map of all cores and what they (prob) are working on.

## §Example

- Input: 3 services, 0 and 1 are 100% parallel and 2 is single threaded.
`-`

means no work for*0.5s*.`#`

means full work for*0.5s*. We see the first service starts after 1s and runs for 3s The second one starts a sec later and runs for 4s. The last service runs 2.5s after the tick start and runs for 1s. Read left to right.

ⓘ

```
[--######------]
[----########--]
[-----##-------]
```

- Output: a Map that calculates where our 6 cores are spending their time. Here each number means 50% of a core is working on it. A ‘-’ represents an idling core. We start with all 6 cores idling. Then all cores start to work on task 0. 2s in, task1 starts and we have to split cores. 2.5s in task2 starts. We have 6 physical threads but work to fill 13. Later task 2 and task 0 will finish their work and give more threads for task 1 to work on. Read top to bottom

ⓘ

```
0-1s [------------]
1-2s [000000000000]
2-2.5s [000000111111]
2.5-3.5s [000001111122]
3.5-4s [000000111111]
4-6s [111111111111]
6s.. [------------]
```