I3 4170 ghz vs I5 8400 ghz

Don't just look at the clock speed and draw conclusions about a CPU. Those days are long gone. The i3 is a 5-year old dual core cpu and the i5 is a new 6-core one based on the latest Intel architecture. You can't compare those 2 CPUs. The i5 is miles ahead of the i3.
 
The i5 8400 boosts to 3.8ghz under heavy loads on all cores.

Take the ipc increase imto account from haswell to kaby lake & thats the equivalent of 4.1ghz on the i3 4170.

& thats not even taking into consideration the i5 has 3 x the number of physical cores & the newer platform runs much faster ram speeds