in reply to Calculating time between two events in a log.
G'day perlguyjoe,
Welcome to the monastery.
Assuming the ,NNN after each HH:MM:SS represents NNN milliseconds, you can use Time::Piece to calculate the time difference like this:
$ perl -Mstrict -Mwarnings -le ' use Time::Piece; my $tp_format = "%Y-%m-%d %H:%M:%S"; sub get_ms { my ($ts, $ms) = split /,/ => shift; Time::Piece->strptime($ts, $tp_format)->epoch * 1000 + $ms; } my $invoke = "2013-08-09 13:00:23,784"; my $success = "2013-08-09 13:00:23,791"; print "Time diff: ", get_ms($success) - get_ms($invoke), "ms"; ' Time diff: 7ms
Please do the following prior to posting again:
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Calculating time between two events in a log.
by perlguyjoe (Novice) on Aug 13, 2013 at 17:09 UTC | |
by kcott (Archbishop) on Aug 14, 2013 at 05:09 UTC |