I just checked Google Earth.
Edinburgh is slightly closer than Berwick (about 12 minutes); Dunbar takes a bit longer (another 10 minutes).
If you are coming by train from England, it takes close to an hour to travel from Berwick to Edinburgh, so overall the journey will be quicker via Berwick.