What is the forumla used to calculate how much gas needs to be used? are the values just determined arbitrarily or was there some kind of benchmarking?
The calculations for the original gas costs can be found in this spreadsheet. The costs are based on a weighted average of approximate costs (compute time, history size increase, state size increase). The results were then rounded off and tweaked somewhat arbitrarily based on perceived DoS vulnerability and frequency of use.
The current gas prices are slightly different, due to adjustments over time, such as in EIP 150.