source
is a builtin, not an external command, so using the external time
to time it doesn't make sense. Do either of:
TIMEFMT=%E
for file in ${(M)config_files}
do
time (source file)
done
Or:
for file in ${(M)config_files}
do
\time -f %E zsh -c 'source "$1"' zsh "$file"
done
In the former, the subshell is necessary because:
Additional note: The time builtin applied to any construct that is
executed in the current shell, is silently ignored. So although it's
syntactically OK to put an opening curly or a repeat-loop or the like
immediately after the time keyword, you'll get no timing statistics.
You have to use parens instead, to force a subshell, which is then
timed.
And in the latter case, you're starting a new zsh instance for each file. So, in both cases, there's no way for easily timing dependent scripts (i.e., where one config file does something that is required by or somehow affects another config file). Alternately, you can save the output of time
after each source, which will give you cumulative timing:
TIMEFMT=%E
{time} 2> times
for file in ${(M)config_files}
do
source file
{time} 2>> times
done
Then you can use awk
or something to get the individual timings:
awk 'NR != 1 {print $0 - prev} {prev = $0; getline}' times