There are many factors involved in learning a foreign language, such as age, aptitude, attitude, and learning and communication strategies.
 
Age: On the one hand, it’s common sense that the younger the student is, the better, although this can also vary depending on the other factors. On the other hand, it’s also common sense that the day you stop learning is the day you die.
 
Aptitude: The more gifted you are, the better, but don't forget that it’s the combination of the other factors plus talent that will determine the rate of success. In other words, talent is not enough.
 
Attitude: The more integrated you feel among the native speakers of the target language, the more likely you’ll engage in the challenge of learning it. It means that if you’re the 'Brit-abroad' type of person, you’re a serious candidate to drop it sooner or later.
 
Learning Strategy: This has to do with your history and learning beliefs as a learner, and in particular as a foreign language student. Firstly, learning is an active process and therefore depends mostly on the learner. The role of the teacher is merely to facilitate the learning of the student acting as a catalyst. There’s no such thing as passive learning. Successful students set themselves final long-term goals, possibly very ambitious, which they break down into smaller goals which are achievable in the short-term. In short, students must be in charge of their own learning enterprise.
 
Communication Strategy: Communication is configured under a socially conventionalised set of principles and rules. In order to be a successful language learner, it’s fundamental that you master the target language conventions. That’s exactly why literal translation proves ineffective most of the time. Therefore, the more you use the target language as a means of communication in class, the more exposed you’ll be to its conventions and the more such conventions will be stored in your long-term memory.
 
Hopefully this information will enable you to set your own algorithm to find out how long it will take you to lean Portuguese.