There isn't nearly as much to figure out as you seem to think.
Let's say that you have a scene in front of you that is nicely illuminated and doesn't really need flash at all, and you meter for, and set a manual exposure for, an ambient exposure that would have been absolutely perfect. Then, for some inexplicable reason, you decide to add manual flash (metered with an external flash meter and using manual flash settings, just to keep the camera's brain out of the equation) with no compensation at all. The result will be a one-stop overexposure (twice as much light as needed for a proper exposure) of the parts of the scene that are illuminated fully by both the ambient lighting and the flash, and one stop over isn't exactly an unrecoverable tragedy most of the time. So the worst a camera can do, assuming the TTL metering for ambient and flash are not connected in any way, and that the system is as brain-dead as the all-manual scenario described, is a one-stop overexposure of some parts of the image (say, certain planes of a subject's face). If you're using an older camera, or one of the less-sophisticated current or recent models, you can probably confirm that that's exactly what will happen when flash isn't needed and no compensation is dialed in.
The metering can be pretty unsophisticated. A single medium-low-power flash burst is fired (1/32 power is usual); a power level that is both high enough to register if full power would have been warranted, but low enough that it won't overpower the metering circuit altogether at the flash's minimum specified distance. Remember that the flash meter doesn't have to create a nice noise-free image, nor does it have to use nice small pixels to record image details. The metering sensors can have a much greater dynamic range than the imaging sensors, especially in an SLR-type camera where it's easy to use a completely separate sensor for metering. It's a simple thing to scale that reading up or down to a level that would have created a proper exposure for the "interesting" part of the picture. (The flash meter, if it's metering the whole image in segments, "knows" that it's unlikely that the flash will illuminate the entire scene evenly. It will either base the metering on the brightest part of the image or on the part of the image that is in focus or selected for spot metering - if you happened to be using flash exposure lock and a meter-and-recompose strategy.) And it may (depending on the camera) take into account ambient lighting as well as flash. Again, that can be done very quickly, since the metering sensor doesn't have to get a proper exposure, it just needs enough of a reading to tell what would happen at the settings you're using. It is not the case that each of the flashes is metered independently or that the system needs to make several attempts to arrive at a correct exposure; everything can be determined from one master flash exposure reading.
After that, it's simple matter of telling each of the flashes what power level to fire at, given both the metering and the exposure compensation you have selected for the group the flash belongs to. That may take a while with an optical triggering system, since it involves timing pulses, channel and group codes, and a power setting for each of the groups you have active in your flash setup. If you are using multiple flashes in multiple groups, how you have the flashes arranged will have a great impact on the resulting exposure - you may have several flashes ganged together in a modifier; you may have flashes in the same group at different distances from elements in the scene, or have different modifiers on each, etc. It is easy to make things go very badly with a multiple flash TTL setup if you don't understand that (which is probably why a lot of folks bail out of TTL and go all-manual instead of trying to figure out what the problem is). TTL flash is just an aid; you still have to understand the basics of lighting when using more than one flash.