Note that I am talking about the gas, not gas price. While testing a contract, I see different amount of gas used for invocation of same method. The method does not have any branching so every single time the same flow is executed so how is it possible that invocation of same method can result in different gas amount used?
And if that's possible then can we take the gas from test networks and use them as reference for setting gas limits when deploying to main network? I believe gas should be same irrespective of main or test network but gas price will obviously be higher in most cases on main network.
UPDATE:
I am using transfer method of OpenZappelin's BasicToken contract. Link to contract file - https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}