Suppose I have a log file from a web server with response time to a request:
_1st_request 1334 _2nd_request 345 _3rd_request 244 _4th_request 648 ......... etc
Is there an easy way with a bash script to find the top decile (10- quantile )? In other words, to answer the question: how slow was the slowest query if I exclude the slowest 10% of the queries?
awk '{print $2}' | sort -rn | perl -e '$d=.1;@l=<>;print $l[int($d*$#l)]'
It would be more elegant to do all this in perl. If you want to use a temporary file, you can use wc + head / tail to select a quantile from a sorted list of numbers.
, , , , 10% .
FILE=responseTimes.log TMPFILE=tmpfile sort -k 2 -n $FILE > $TMPFILE LINECOUNT=`wc -l $TMPFILE | sed -e 's/^ *//' -e 's/ .*$//'` TARGETLINE=echo "$LINECOUNT * 9 / 10" | bc sed -n "$TARGETLINE{p;q;}" $TMPFILE
, .
Source: https://habr.com/ru/post/1716050/More articles:WPF flag control does not respond to MouseLeftButtonDown event - checkboxAdditional property Readonly in the VB.Net interface - propertiesGet the first n lines matching a specific pattern (with Linux commands) - linuxhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1716048/bash-script-to-automatically-create-symlinks-to-subdirectories-in-a-tree&usg=ALkJrhjN6goNe7yS-hAjgumoMvBY1n2fbQHow can I make an interface property read-only in VB.NET? - oopReading PPM Image in C # - c #Tracking Programming Design Effectiveness - designHabits that help the context easily switch between tasks - time-managementhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1716054/use-css-to-create-multiple-elements-that-take-up-the-entire-width-of-the-parent&usg=ALkJrhgGfux4TBvnlsGY_bQiT4Ssx38dwgCan sqlite load individual tables from separate files? - phpAll Articles