Compression ratio is a ration of the volume of the cylinder when the piston is all the way down compared the the volume of the cylinder when the piston is all the way up in the cylinder. Basically, how much the volume is squeezed as the piston moves from bottom dead center to top dead center. It is set by the design of the engine. I can be changed by changing pistons, or by enlarging the area around the valves in the cylinder head. You can also add a thicker head gasket to increase the volume. Not something the do it yourselfer generally messes with. Is done more often on non turbo cars when converting to turbo. A turbo car generally has a lower compression ratio. This helps prevent detonation. An NA car is often around 10 or even 11 to 1. When you go forced induction it is often too much to prevent proper combustion in a high compression engine.
Now if you are asking about a compression test, it measures how much psi is made when the piston moves up. The factory will state a number for the particular engine that is normal and a minimum number that indicates there is a problem like wear within the cylinder. Measured with a simple pressure gauge connected to the spark plug hole.