Anecdata of one, but compiling our product at work on my three machines (a 2019 intel macbook pro, a 2020 10 core intel imac and an m1 mac mini), the macbook pro is the slowest, but the imac isn’t that much faster than the mini. it’s something like:
Where the M1 really blows any other CPU away is single-threaded performance; multi-threaded performance is just normal. So it's not surprising that it's not faster than your 10-core iMac when compiling (which I assume is using 100% of every core).
In fact, given that the M1 is an 8-core CPU and your iMac has a 10-core CPU, the fact that they take 5 and 4 minutes respectively to compile seems to indicate that they're fairly similar in multi-threaded performance (and the iMac wins only because it has more cores).
- macbook pro: 9 minutes
- mini: 5 minutes
- imac: 4 minutes