I already posted the formula for horsepower.
Horsepower = torque X RPM / 5252
There are various conversions, for example "kilowatts to HP" (because early engine dynomometers were "eddy current", meaning the engine was used to generate electricity to determine how much power it produced).
One horsepower is the power to lift a specified weight (550 pounds) one foot in one minute. Or about 750 Watts.
You use an engine dynomometer of some sort to measure torque and RPM, and the formula tells you what the HP is.
These days, the most common type of dyno is the water brake dyno, however the older eddy current dynos are still used, and the current "hot ticket" is the inertia dyno, which has a flywheel that the engine accelerates.