Also, for those checking in at MAD keep in mind that earlier is better - particularly in the busy summer months of July / Aug. They only had one CE & ET check-in agent each. It just takes one or two passengers with a complicated check-in to completely slow down check-in.
Once you get through that you have security, the train to T4S, and immigration. Immigration was running at 40-60 mins yesterday (~10:30am), with queues down the escalator back to the train station. Allow for time (3h before)!