'How to time fish prompt

I'm considering switching from zsh to fish, however before I do I want to compare the speeds at which the prompts load. I have a ZSH function which would time 10 times how long it would take for the prompt to load.

timeshell() {
  shell=${1-$SHELL}
  for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}

I'm struggling to implement the same code into something fish compliant. for instance the following:

time for i in 1 2 3 4 5 6 7 8 9 10; fish; end

Wil actually load the fish shell prompt, cancelling the command.

Any thoughts? Thank you.



Solution 1:[1]

Within fish, you can time a function:

> time fish_prompt
Executed in    6.71 ms    fish       external
   usr time    1.72 ms    0.00 ms    1.72 ms
   sys time    6.07 ms    6.07 ms    0.00 ms

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zanchey