An engine map - a set of curves of engine efficiency vs. both engine speed and engine torque - requires a measurement of both of those quantities. Where and how is engine torque measured to produce such a map?
The manufacturer's put their engines on dynamometers during the design and build phases.
In fact, there are test engines designed to be varied in many ways to test different parameters, one manufacturer is, or was, Ricardo. One engine they produced, that I spent many hours running, had variable compression ratio, which gives a huge amount of combinations when you start playing with mixture strengths, timing etc.
So, they produce a characteristic map varying all the different parameters and find the optimum settings, or at least, what they consider optimal for the life and power output they want to go to market with.
This is why the aftermarket tuners can re-program the ecu in many cases for more power, usually it has a downside on the longevity of one or more of the components though.