Search code examples
logparser

Using LogParser to calculate method execution duration


I have log-file like this:

30.09.2013  15:28:05    Start   MethodName  QueryGuid
***** Some logs ****
30.09.2013  15:58:32    Stop    MethodName  QueryGuid

I want to use LogParser to calculate method execution duration, but i have no idea how. As far as i know LogParser do not support sub-queries.


Solution

  • I've got an answer on http://mlichtenberg.wordpress.com/2011/02/03/log-parser-rocks-more-than-50-examples/#comment-480

    SELECT MethodName, QueryGuid, 
    SUB(
    MAX(TO_INT(TO_TIMESTAMP(Date, Time))),
    MIN(TO_INT(TO_TIMESTAMP(Date, Time)))
    ) AS SecondsElapsed
    FROM YourLogFile
    GROUP BY MethodName, QueryGuid