The AMD Ryzen 7 2700X wins in 8 out of 14 comparable specs, with 3 ties. Its biggest advantage is Threads (167% better).
Core i5-9400F wins in 3 specs (Max Turbo Power: 54% better).
Recommendation
Choose Ryzen 7 2700X if you want the best overall performance — especially threads.
Choose Core i5-9400F if max turbo power matters more to you.