In order to achieve a meaningful result the engine must be given some resistance to work against. An engine dynamometer is a computer controlled mechanical resistance which takes the place of the vehicle's weight, the losses of the drive train, the tires, and aerodynamics. A vehicle dynamometer is the same in principle, but the resistance is applied at the wheels rather than directly at the engine's flywheel. Locomotives typically provide their own resistance using their generator; so instead of a dynamometer, the generated electrical power is measured. In any other case there must be a way to provide resistance and measure power.
The activity of an engine, and therefore the amount of power it produces and for how long, is often predetermined. For instance, applicable regulations may specify exactly what torque an engine produces, and at what speed, for each second of a twenty minute test. Similarly if an entire vehicle is tested, the vehicle's speed is prescribed for every second. These test schedules are not only mandated by many regulations, but provide a basis for comparison even if not performing a test for certification purposes.
In the end, the amount of work the engine has done is characterized in at least one of the following ways: brake horsepower hours, or miles. Miles is simple and only applies on a vehicle dynamometer or on-road testing. Brake horsepower hours is the mechanical work the engine performed during the test. As a result the final reported results are typically in grams per mile or grams per brake horsepower hour, or both, for each gas or for particulate matter. An engine or vehicle that complies with applicable regulations cannot exceed certain limits for each of those figures. Which regulations apply, and what those limits are, depend on numerous factors, but usually the most important factors are the engine type, size, purpose and year.