Barrel length is measured from the breech to the muzzle. Lock a bolt into the breech end, make sure there is no removable muzzle device attatched, insert a dowel or rod into bore until it touches the bolt face. Mark a line on the rod at the muzzle, remove & measure.
Barrel length is measured muzzle to breech face on any rifle or handgun.
For simplicity sake, on an AR-15 rifle, you can measure the complete barrel and subtract 3/8" as that's the nominal dimension from the breech face (bolt locked in battery in the barrel extension) to the rear of the barrel extension.
If you are shortening a barrel, just keep an extra 1/8" or so on there so there's no question about legality.
Most 16" barrels come from the manufacturer's at 16.25" length if you actually measure them...