Michael Portillo did an excellent program on this.
Depends really whether you want to dispose of the criminal in a way that is least distressing for all concerned, or whether you think a bit of suffering as they go is no bad thing.
[not going into whether capital punishment is a good thing or not for the purposes of this discussion]
Cyanide, iirc, is very fast acting in the right concentrations, but in the short while to take effect, agonising, and in lower concentrations can lead to prolonged (minutes) of pain before they die.
Portillo concluded that nitrogen (or other inert gas) hypoxia is the best method. Like taking pilots to altitude and then getting them to take their masks off, they rapidly become disorientated, then almost drunk, and then unconcious and then finally hypoxic. He did similar in a barometric chamber to near unconciousness and described it as thoroughly pleasant.