Sampling rate while logging

Hello all

How can I log a particular topic at a fixed sampling rate ? Adding to topic to logger.cpp and providing the time interval does log the data but still its not logging at the sampling rate I want. If I put 20ms as the time interval I should be getting 50Hz but instead i’m getting something close 80Hz . How can I precisely control the sampling rate using logger ?

Thanks in advance