Here is what Intel says.
https://ark.intel.com/compare/65523,65523,126684
The 8700K has two extra cores, can handle 4 more threads, has ~1GHz more speed, along with 4 generations of core improvements. (some of which I admit are sub 10% compared to previous gen.) Considering the extra cores and clock speed, the 8700K is a much better CPU.
That being said these are K CPUs. the 2500K could hit 5GHz easy, with higher being possible. From what I've seen, 7 and 8 series tend to top out around the same speed. At this point the clock speeds are more or less the same. The difference would be the per core improvements which have happened over the years. (From what I've seen, there are no real changes in IPC from 7 to 8 series. 8's are better because they have more cores.) Overclocked to ~5Ghz, I would think there would be a difference in performance of around 25-35%. If the task can make use of all the cores in the 8 series, you'd see a much larger change. Same if you had both at stock and the 8700K had that extra 1GHz depending on boost.