To piggyback, the best way to measure alkalinity (and in fact even the definition) relies on a titration, but instead of a color endpoint, it's a pH endpoint. The lab grade alkalinity tests add tiny increments of acid until a specific pH is reached at which all titratable bases, in our case we're primarily interested in the most prevalent carbonate in marine waters as bicarbonate (HCO3) have been consumed.