Suppose you have setup replication and would like to know how to find the time taken to create a snapshot. and time taken to deliver a snapshot.
Run the script in the distribution database.
Snapshot creation time
select mh.agent_id,ma.name,ma.publisher_id,ma.publisher_db,ma.publication,mh.start_time,mh.duration,mh.comments
from mssnapshot_history mh inner join mssnapshot_agents ma on ma.id=mh.agent_id where mh.runstatus=2 order by mh.duration desc
Snapshot delivery time
select ma.id,ma.publication,ma.publisher_id,ma.name,mh.start_time,convert(float,rtrim(substring(substring(comments,charindex('in ',comments)+3 , (len(comments) - 12)),0,charindex('milliseconds',substring(comments, charindex('in ',comments)+3 ,(len(comments) - 12))))))/1000 as SnapshotDelivery from msdistribution_history mh inner join msdistribution_agents ma on ma.id=mh.agent_id where mh.comments like 'Delivered snapshot %'