I have the following section of code:
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerECHLane") {
$11 ~ /ms/ ( SUM10 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min10 = (min < $11 ? min : $11)
max10 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
}
and I was wondering what !i++
does as I know that i++
increments the variable after it has been used and that ++i
increments the variable before it is used.
I have tried Google but it is only showing me the differences between i++
and ++i
Thanks in advance.
As Promised please see the following for the full script:
#!/usr/bin/gawk -f
BEGIN {
min01 = 0
min02 = 0
min03 = 0
min04 = 0
min05 = 0
min06 = 0
min07 = 0
min08 = 0
min09 = 0
min10 = 0
max01 = 0
max02 = 0
max03 = 0
max04 = 0
max05 = 0
max06 = 0
max07 = 0
max08 = 0
max09 = 0
max10 = 0
SUM01 = 0
SUM02 = 0
SUM03 = 0
SUM04 = 0
SUM05 = 0
SUM06 = 0
SUM07 = 0
SUM08 = 0
SUM09 = 0
SUM10 = 0
} #End of BEGIN
{ #Start of MID
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerPackingInfeedHanging") {
$11 ~ /ms/ ( SUM01 += $11)
if ($11 ~ /ms/) {
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min01 = (min < $11 ? min : $11)
max01 = (max > $11 ? max : $11)
} #End of for
}} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerPackingAreaNOK") {
$11 ~ /ms/ ( SUM02 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min02 = (min < $11 ? min : $11)
max02 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerPackingAreaMPANOK") {
$11 ~ /ms/ ( SUM03 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min03 = (min < $11 ? min : $11)
max03 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerPackingOrderBufferHanging") {
$11 ~ /ms/ ( SUM04 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min04 = (min < $11 ? min : $11)
max04 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerTUNotification") {
$11 ~ /ms/ ( SUM05 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min05 = (min < $11 ? min : $11)
max05 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerLaneStatusLaneLocker") {
$11 ~ /ms/ ( SUM06 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min06 = (min < $11 ? min : $11)
max06 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerPackingHangingBufferLane") {
$11 ~ /ms/ ( SUM07 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min07 = (min < $11 ? min : $11)
max07 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerLaneStatusHangingMPA") {
$11 ~ /ms/ ( SUM08 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min08 = (min < $11 ? min : $11)
max08 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerMPAHangingBufferLane") {
$11 ~ /ms/ ( SUM09 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min09 = (min < $11 ? min : $11)
max09 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
} else
if (substr($12,match($12,":")+1,match($12,")")-15) == "TelegramHandlerECHLane") {
$11 ~ /ms/ ( SUM10 += $11)
!i++ (min = $11)
!i++ (max = $11)
{
for (j= NR; j<= FNR; ++j) {
min10 = (min < $11 ? min : $11)
max10 = (max > $11 ? max : $11)
} #End of for
} #End of for wrapper
}
MSG_TYPE[substr($12,match($12,":")+1,match($12,")")-15)]++;
} #End of MID
END {
for (b in MSG_TYPE)
if (b == "TelegramHandlerPackingInfeedHanging") {
print b
print "MIN: "min01
print "MAX: "max01
print "AVG: "SUM01/FNR"ms"
} else
if (b == "TelegramHandlerPackingAreaNOK") {
print b
print "MIN: "min02
print "MAX: "max02
print "AVG: "SUM02/FNR"ms"
} else
if (b == "TelegramHandlerPackingAreaMPANOK") {
print b
print "MIN: "min03
print "MAX: "max03
print "AVG: "SUM03/FNR"ms"
} else
if (b == "TelegramHandlerPackingOrderBufferHanging") {
print b
print "MIN: "min04
print "MAX: "max04
print "AVG: "SUM04/FNR"ms"
} else
if (b == "TelegramHandlerTUNotification") {
print b
print "MIN: "min05
print "MAX: "max05
print "AVG: "SUM05/FNR"ms"
} else
if (b == "TelegramHandlerLaneStatusLaneLocker") {
print b
print "MIN: "min06
print "MAX: "max06
print "AVG: "SUM06/FNR"ms"
} else
if (b == "TelegramHandlerPackingHangingBufferLane") {
print b
print "MIN: "min07
print "MAX: "max07
print "AVG: "SUM07/FNR"ms"
} else
if (b == "TelegramHandlerLaneStatusHangingMPA") {
print b
print "MIN: "min08
print "MAX: "max08
print "AVG: "SUM08/FNR"ms"
} else
if (b == "TelegramHandlerMPAHangingBufferLane") {
print b
print "MIN: "min09
print "MAX: "max09
print "AVG: "SUM09/FNR"ms"
} else
if (b == "TelegramHandlerECHLane") {
print b
print "MIN: "min10
print "MAX: "max10
print "AVG: "SUM10/FNR"ms"
}
} #End of END
A example of the output that is getting returned:
TelegramHandlerPackingInfeedHanging
MIN: 19.7ms
MAX: 19.7ms
AVG: 3.05067ms
TelegramHandlerPackingAreaNOK
MIN: 25.3ms
MAX: 25.3ms
AVG: 0.00706937ms
TelegramHandlerPackingAreaMPANOK
MIN: 22.3ms
MAX: 22.3ms
AVG: 4.26834e-05ms
TelegramHandlerPackingOrderBufferHanging
MIN: 12.0ms
MAX: 12.0ms
AVG: 1.60741ms
TelegramHandlerTUNotification
MIN: 8.7ms
MAX: 8.7ms
AVG: 4.00978ms
TelegramHandlerLaneStatusLaneLocker
MIN: 15.0ms
MAX: 15.0ms
AVG: 0.0527127ms
TelegramHandlerPackingHangingBufferLane
MIN: 23.9ms
MAX: 23.9ms
AVG: 13.3463ms
TelegramHandlerLaneStatusHangingMPA
MIN: 312.5ms
MAX: 312.5ms
AVG: 0.0126846ms
TelegramHandlerMPAHangingBufferLane
MIN: 57.0ms
MAX: 57.0ms
AVG: 0.135032ms
TelegramHandlerECHLane
MIN: 7.0ms
MAX: 7.0ms
AVG: 2.81495ms
This is partly doing what I wanted it to. Return the message,substr($12,match($12,":")+1,match($12,")")-15)
along with the min
time took to process, max
time took to process and the AVG
time to process. Although the min
and max
values are the same so I think that the values are getting overwritten rather than being worked out individually and them saved to the variable min01 - min10, max01 - max10, SUM01 - SUM10.