Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First - you need to make it easier to parse the different fields. A simple way is to change a semicolon to a space using </p> <pre><code>tr ";" " " &lt;logfile|awkscript </code></pre> <p>Second, you need to create a table of low and high values. I'm using an associative array whose index is the name of the column. I do this in the BEGIN section. </p> <p>You need to count when a value is within the low and high values. I do this in the middle section.</p> <p>In the END section, I print out the values. I use 2 similar printf format strings to make sure the headers and values line up nicely:</p> <pre><code>#!/usr/bin/awk -f BEGIN { low["&lt;1ms"]=0;high["&lt;1ms"]=1 low["1-10ms"]=1;high["1-10ms"]=10 low["10-100ms"]=10;high["10-100ms"]=100 low["100-500ms"]=100;high["100-500ms"]=500 low["&gt;500ms"]=500;high["&gt;500ms"]=1000000000 } { # Middle section - for each line duration=$3 for (i in high) { if ((duration &gt; low[i]) &amp;&amp; (duration &lt;= high[i]) ) { # printf("duration: %d, low: %s,high: %s\n", duration, low[i], high[i]); total+=duration # total duration bin[i]++ # store a count into different bins count++ # total number of measurements } } } END { average=total/count FMT="%-10s %10s %10s %10s %10s %10s\n" NFMT="%-10.3f %10s %10s %10s %10s %10s\n" printf(FMT,"AVG", "&lt;1ms", "1-10ms", "10-100ms", "100-500ms", "500+ms") printf(NFMT,average, bin["&lt;1ms"], bin["1-10ms"], bin["10-100ms"], bin["100-500m\ s"], bin["500+ms"]) } </code></pre> <p>When I run this with your data, I get</p> <pre><code>AVG &lt;1ms 1-10ms 10-100ms 100-500ms 500+ms 282.916 4 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload