I'm not sure how 2d8 damage with a cantrip is the same as 4d6+8. It's average 9 damage vs average 23. That's without factoring it hit chances. Most enemies have about +1 to saves. It's DC 15 to save for a 18 Wis cleric. So enemies save on a 14+ or about 35% of the time. Most enemies have AC 13 or so which means the fighter hits on a 6. So, they hit 75% of the time. That means it is 5.85 vs 17.25. So, the fighter does nearly triple damage.
That's assuming 5th level Fighter with 18 strength using a greatsword vs 5th level Cleric using Sacred Flame.
Way to chery pick a specific class versus class comparison at a level of your choice with a weapon of your choice. The Cleric can have a Spiritual Weapon going, and have a shield out.
A Wizard can Haste themself at level 5 and cast 2 cantrips, each doing 2d12, so 4d12, or at 6 when they get potent cantrip for half on a miss. 11 When it is 3d12 x 2, 14 when they are all maxxed for either 72, 54 or 36 damage per turn.