Just because your engine was manufactured to have a certain compression ratio doesn't mean its true "asassembled" ratio is close to that specification. This is very important, since ignition timing, fuel delivery and overall performance are directly related to an engine's compression ratio.
Many engine components must be set up and optimized to the compression ratio, so knowing exactly what that number is becomes a critical measurement, especially in situations where different heads, valves, camshafts and other internal parts have been changed.
So how is it done? Actually, it's quite easy but first we need to define some terms:
Bore: The diameter of each cylinder expressed in inches.
Stroke: The length of travel of the rod/piston. Note: you can use the manufacturer's specification for this value, but if a different crankshaft with a nonstock "throw" is used or different rods and pistons are used, the stroke must be measured.
Combustion Chamber Volume: This is the total volume, in cubic centimeters, of each combustion chamber (the depression in the head surface that contains the valves and spark plug.) To obtain the volume, place the head level and inverted on the bench, with its valves and plug(s) installed. Fill each chamber with alcohol or mineral spirits from a measured container or syringe until the chamber is full and surface tension keeps the fluid from running out. Note the exact amount for each combustion chamber and add up the totals, converting any measurement to cubic centimeters. Note: 1 cubic centimeter = .061 cubic inch. To convert ounces to cubic centimeters, divide the cc number by 29.57
Deck Height Volume: This is the area of bore between the top of the piston and the top surface of the block when the piston is at the very top of its stroke. The formula for calculating this value is: bore x bore x .7854 x measured deck height.
Head Gasket Volume: The head gasket takes up space and is therefore part of the cylinder's overall volume. To calculate the head gasket's volume, use the formula: bore x bore x .7854 x compressed gasket thickness.
Swept Volume: The swept volume is the displacement of one cylinder as calculated by the formula: bore x bore x stroke x.7854
Constant Volume: The constant volume is the volume into which the swept volume is compressed on each compression stroke. This value includes the combustion chamber volume, head gasket volume and deckheight volume.
Once all these values are measured and calculated, we can accurately calculate the compression ratio of this specific engine. The formula for computing compression ratio is:
CR= 
Swept volume + Deck Height volume + Head gasket Volume + Combustion Chamber volume

Deck height Volume + Head Gasket Volume + Combustion Chamber Volume 
Of course, there are situations where everything isn't this simple. This formula only applies to "flattop" pistons and not domed or dished pistons. Even flattop pistons have little cuts in them for valve clearance, called "valve relief."
Not to worry, however. For domed pistons the manufacturers provide the values that these pistons reduce the combustion chamber volumes, so just do the arithmetic. For dished pistons or valve reliefs, use the syringe method to measure the additional volumes and add to the combustion chamber volume.