How to test MySQL master-slave replication latency and get the exact time of slave library latency (accurate to milliseconds)
INSERT INTO latency (master, slave) VALUES
    (NOW(3),      -- same time on Master and Slave
     SYSDATE(3))   -- time at which this query was run on each


Then diff them to see the latency.

Caveats:


Running with --sysdate-is-now would prevent the trick from working.  Test via SELECT NOW(6), SYSDATE(6);.
I have not tested this.
SYSDATE is "unsafe for replication" (but we are taking advantage of that!); however, the binlog_format may impact it.