This calculation is made for fully upgraded guns using piercing rounds and laser turrets (it would only look worse for guns with less upgrades).
Energy cost of 1 piercing rounds magazine:
7275 kJ
=> 727.5 kJ / shot
Energy needed to kill biters (with fully upgraded turrets):
Small biter:
Gun:
1 shot => 728 kJ
Laser:
0.2s of laser => 120 kJ
Gun 6.06x as expensive
Medium biter:
Gun:
4 shots => 2910 kJ
Laser:
1.2s of laser => 720 kJ
Gun 4.04x as expensive
Big biter:
Gun:
24 shot => 17460 kJ
Laser:
6.8s of laser => 816 kJ
Gun 21.4x as expensive
This makes the balance of defences quite strange, as not only do lasers require no raw resource upkeep, they also have lower power requirements!
My full workings are presented below, feel free to check them. I've done the calculation longhand, as no available resource calculators seem to take into account energy usage of production.
I used the shots to kill data from this post: https://forums.factorio.com/forum/vie ... =20#p36394