Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Testing
Commits
a84c07b1
Commit
a84c07b1
authored
May 04, 2020
by
Jean-Claude BAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generic scripts for data mining
parent
880c0629
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
938 additions
and
0 deletions
+938
-0
genAll.sh
sw/xena-tester/tools/genAll.sh
+5
-0
genData.sh
sw/xena-tester/tools/genData.sh
+228
-0
genGraphs.sh
sw/xena-tester/tools/genGraphs.sh
+150
-0
genLib.sh
sw/xena-tester/tools/genLib.sh
+210
-0
genTable.sh
sw/xena-tester/tools/genTable.sh
+224
-0
logCleaner.sh
sw/xena-tester/tools/logCleaner.sh
+121
-0
No files found.
sw/xena-tester/tools/genAll.sh
0 → 100755
View file @
a84c07b1
#!/bin/bash
genData.sh
genGraphs.sh
genTable.sh
sw/xena-tester/tools/genData.sh
0 → 100755
View file @
a84c07b1
#!/bin/bash
source
genLib.sh
inputFile
=
$cleanLogName
fileHeader
=
`
basename
$inputFile
.csv
`
function
latencyValueAdjustment
()
{
echo
`
echo
"scale=3;(
$1
*1000)/1"
| bc
`
# div by 1 to take into account the scale
}
function
float3ValueAdjustment
()
{
echo
`
echo
"scale=3;
$v
/1"
| bc
`
# div by 1 to take into account the scale
}
function
portValueAdjustment
()
{
echo
`
echo
$1
|
grep
-o
-e
[
0-9]
$`
}
# Value adjusment functions
valueAdjustments[tkIdxLatencyAvg]
=
latencyValueAdjustment
valueAdjustments[tkIdxLatencyMin]
=
latencyValueAdjustment
valueAdjustments[tkIdxLatencyMax]
=
latencyValueAdjustment
valueAdjustments[tkIdxRxBer]
=
float3ValueAdjustment
valueAdjustments[tkIdxPort]
=
portValueAdjustment
function
generateDataHeader
()
{
local
i
=
0
echo
-n
"# "
for
idx
in
${
tkIdxs
[@]
}
;
do
echo
-n
"
${
cvsTitles
[
$idx
]
}
"
done
echo
""
}
function
generateData
()
{
local
line
=
$1
local
tokens
local
idx
=
0
local
i
=
0
OLDIFS
=
$IFS
IFS
=
","
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
for
tkIdx
in
${
tkIdxs
[@]
}
;
do
i
=
${
csvColumn
[
$tkIdx
]
}
v
=
${
tokens
[
$i
]
}
exp
=
`
echo
$v
|
grep
-o
-e
E
`
if
[
-n
"
$exp
"
]
;
then
# Convert notation
v
=
`
echo
$v
|
awk
'{printf("%.10f\n", $1)}'
`
fi
if
[
-n
"
${
valueAdjustments
[tkIdx]
}
"
]
;
then
v
=
$(
${
valueAdjustments
[tkIdx]
}
$v
)
fi
if
[[
"
$v
"
=
[
.]
*
]]
;
then
v
=
"0
$v
"
;
fi
# All value strating with .xxx changed to 0.xxx
if
[[
"
$v
"
=
[
-]
*
]]
;
then
>
&2
echo
"
$v
$tkIdx
${
tokens
[
$i
]
}
"
;
fi
echo
-n
"
$v
"
done
echo
""
}
function
learningFromCsv
()
{
local
line
=
$1
local
tokens
OLDIFS
=
$IFS
IFS
=
","
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
for
idx
in
"
${
!tokens[@]
}
"
;
do
local
j
=
0
token
=
${
tokens
[
$idx
]
}
for
j
in
"
${
!cvsTitles[@]
}
"
;
do
if
[[
"
$token
"
=
${
cvsTitles
[
$j
]
}*
]]
;
then
csvColumn[
$j
]=
$idx
break
;
fi
done
done
displayDebugInfo
}
function
generateFilterNoErrorsData
()
{
local
line
=
"
$1
"
local
list
=(
$tkIdxRxFcsErrors
$tkIdxRxSeqErr
$tkIdxRxMisErr
$tkIdxRxPldErr
$tkIdxRxBer
)
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
for
tkIdx
in
${
list
[@]
}
;
do
if
[
"
${
tokens
[
${
plotDataIdx
[
$tkIdx
]
}
]
}
"
-ne
"0"
]
;
then
line
=
""
break
fi
done
echo
"
$line
"
}
lastLine
=(
""
""
""
""
)
lastFrameSize
=(
0 0 0 0
)
dataFound
=(
0 0 0 0
)
generateLimitsDataRetValue
=
""
# like this because we modify global variable in the function
function
generateLimitsData
()
{
local
line
=
"
$1
"
local
list
=(
tkIdxRxFcsErrors tkIdxRxSeqErr tkIdxRxMisErr tkIdxRxPldErr tkIdxRxBer
)
local
str
=
""
if
[
-n
"
$line
"
]
;
then
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
port
=
${
tokens
[
${
plotDataIdx
[
$tkIdxPort
]
}
]
}
frameSize
=
${
tokens
[
${
plotDataIdx
[
$tkIdxFrameLength
]
}
]
}
if
[
"
$frameSize
"
-ne
"
${
lastFrameSize
[
$port
]
}
"
]
;
then
# new size:
if
[
"
${
dataFound
[
$port
]
}
"
-eq
"0"
]
;
then
str
=
"
${
lastLine
[
$port
]
}
"
fi
lastFrameSize[
$port
]=
$frameSize
dataFound[
$port
]=
0
else
# Same frame size
if
[
"
${
dataFound
[
$port
]
}
"
-eq
"0"
]
;
then
# not found yet
for
tkIdx
in
${
list
[@]
}
;
do
if
[
"
${
tokens
[
${
plotDataIdx
[
$tkIdx
]
}
]
}
"
-ne
"0"
]
;
then
# Error detected
str
=
"
${
lastLine
[
$port
]
}
"
lastFrameSize[
$port
]=
$frameSize
dataFound[
$port
]=
1
break
fi
done
fi
fi
lastLine[
$port
]=
"
$line
"
else
# empty ligne is to trigger the eof
str
=
""
for
port
in
${
!dataFound[@]
}
;
do
if
[
"
${
dataFound
[
$port
]
}
"
-eq
"0"
]
;
then
if
[
-n
"
$str
"
]
;
then
str+
=
$'
\n
'
;
fi
str+
=
"
${
lastLine
[
$port
]
}
"
fi
done
fi
generateLimitsDataRetValue
=
"
$str
"
}
function
genLimitsDataFile
()
{
>
&2
echo
" Generate limits data file
\"
$dataFileLimits
\"
"
local
n
=
1
local
lineCnt
=
`
wc
-l
$inputFile
|
grep
-o
^[0-9]
*
`
while
read
line
;
do
if
[
"
$n
"
-eq
"1"
]
;
then
echo
"
$line
"
>
$dataFileLimits
else
generateLimitsData
"
$line
"
if
[
-n
"
$generateLimitsDataRetValue
"
]
;
then
echo
"
$generateLimitsDataRetValue
"
>>
$dataFileLimits
;
fi
fi
n
=
$((
n+1
))
displayPercentage
$lineCnt
$n
done
<
$dataFile
generateLimitsData
""
# Inform EOF
if
[
-n
"
$generateLimitsDataRetValue
"
]
;
then
echo
"
$generateLimitsDataRetValue
"
>>
$dataFileLimits
;
fi
clearDisplayPercentage
# Split in different files
for
p
in
`
seq
0
$((
$portCount
-
1
))
`
;
do
of
=
`
basename
$dataFileLimits
.dat
`
_
$p
.dat
>
&2
echo
"Generating
$of
"
grep
-e
"^#"
-e
"^
$p
"
$dataFileLimits
>
$of
done
}
function
genFilteredNoErrorsDataFile
()
{
>
&2
echo
" Generate filtered data file
\"
$dataFileFilteredNoErrors
\"
"
local
n
=
1
local
lineCnt
=
`
wc
-l
$inputFile
|
grep
-o
^[0-9]
*
`
while
read
line
;
do
if
[
"
$n
"
-eq
"1"
]
;
then
echo
"
$line
"
>
$dataFileFilteredNoErrors
else
local
str
=
$(
generateFilterNoErrorsData
"
$line
"
)
if
[
-n
"
$str
"
]
;
then
echo
"
$str
"
>>
$dataFileFilteredNoErrors
;
fi
fi
n
=
$((
n+1
))
displayPercentage
$lineCnt
$n
done
<
$dataFile
clearDisplayPercentage
}
function
genDataFile
()
{
>
&2
echo
"Reading CSV file
\"
$inputFile
\"
and generate data file
\"
$dataFile
\"
"
local
n
=
1
local
lineCnt
=
`
wc
-l
$inputFile
|
grep
-o
^[0-9]
*
`
while
read
line
;
do
if
[
"
$n
"
-eq
"1"
]
;
then
learningFromCsv
"
$line
"
generateDataHeader
>
$dataFile
else
generateData
"
$line
"
>>
$dataFile
fi
n
=
$((
n+1
))
displayPercentage
$lineCnt
$n
done
<
$inputFile
clearDisplayPercentage
}
function
main
()
{
genDataFile
scanData
#portCount=4
#plotDataIdx=( [0]=0 [1]=1 [2]=2 [3]=3 [4]=4 [5]=5 [6]=6 [7]=7 [8]=8 [9]=9 [10]=10 )
displayDebugInfo
genFilteredNoErrorsDataFile
genLimitsDataFile
}
main
sw/xena-tester/tools/genGraphs.sh
0 → 100755
View file @
a84c07b1
#!/bin/bash
source
genLib.sh
function
generatePlotScript
()
{
local
title
=
$1
local
outFile
=
$2
local
using
=
$3
local
dataF
=
$4
echo
"set autoscale"
echo
"unset log"
echo
"unset label"
echo
"set xtics auto"
echo
"set ytic auto"
echo
"set ztic auto"
echo
"set pointsize 0.5"
echo
"set title
\"
$title
\"
"
echo
"set xlabel
\"
frame Length (Bytes)
\"
"
echo
"set ylabel
\"
NetLoad (%)
\"
"
echo
"unset zlabel"
echo
"set dgrid3d 30,30"
echo
"set hidden3"
echo
"set style data lines"
echo
"set pm3d "
echo
"set view 68,332"
echo
"set key noautotitle"
echo
"set terminal png size 1024,900"
echo
"set output '
$outFile
.png'"
echo
"splot
\"
$dataF
\"
using
$using
with lines"
}
function
generatePlotScriptLimits
()
{
local
title
=
$1
local
outFile
=
$2
local
plotCommand
=
$3
echo
"set autoscale"
echo
"unset log"
echo
"unset label"
echo
"set xtics auto"
echo
"set ytic auto"
echo
"set pointsize 0.5"
echo
"set title
\"
$title
\"
"
echo
"set xlabel
\"
frame Length (Bytes)
\"
"
echo
"set ylabel
\"
NetLoad (%)
\"
"
echo
"set style data lines"
echo
"set key noautotitle"
echo
"set terminal png size 1024,900"
echo
"set output '
$outFile
.png'"
echo
"
$plotCommand
"
}
declare
-a
plotFiles
function
generateImages
()
{
rm
-f
../
*
.png
for
idx
in
${
!plotFiles[@]
}
;
do
f
=
${
plotFiles
[
$idx
]
}
echo
" Generating image for
$f
"
gnuplot
$f
done
}
function
generatePlotScriptsLimits
()
{
pf
=
"limits"
of
=
"
$pf
.p"
plotCommand
=
"plot"
for
p
in
`
seq
0
$((
$portCount
-
1
))
`
;
do
t
=
"Port
$p
"
df
=
`
basename
$dataFileLimits
.dat
`
_
$p
.dat
if
[
"
$p
"
-ne
"0"
]
;
then
plotCommand+
=
", "
;
fi
plotCommand+
=
"
\"
$df
\"
using 2:3 title
\"
$t
\"
"
done
generatePlotScriptLimits
"Functioning limits"
../
$pf
"
$plotCommand
"
>
$of
plotFiles+
=(
$of
)
}
function
generatePlotScriptsLatencies
()
{
local
titles
=(
"Average Latency (us)"
"Min Latency (us)"
"Max Latency (us)"
"Average Latency - No Errors (us)"
"Min Latency - No Errors (us)"
"Max Latency - No Errors (us)"
)
local
pngFiles
=(
latencyAvg latencyMin latencyMax
latencyAvgNoErr latencyMinNoErr latencyMaxNoErr
)
local
tkIdxList
=(
$tkIdxLatencyAvg
$tkIdxLatencyMin
$tkIdxLatencyMax
$tkIdxLatencyAvg
$tkIdxLatencyMin
$tkIdxLatencyMax
)
local
dataFiles
=(
$dataFile
$dataFile
$dataFile
$dataFileFilteredNoErrors
$dataFileFilteredNoErrors
$dataFileFilteredNoErrors
)
for
i
in
${
!titles[@]
}
;
do
for
p
in
`
seq
0
$((
$portCount
-
1
))
`
;
do
# Latencies
pf
=
"
${
pngFiles
[
$i
]
}
_
$p
"
of
=
"
$pf
.p"
t
=
"
${
titles
[
$i
]
}
- Port
$p
"
tkIdx
=
${
tkIdxList
[
$i
]
}
z
=
$((
${
plotDataIdx
[
$tkIdx
]
}
+
1
))
# +1 because GNUPLOT indexes start at 1
u
=
"2:3:(
\$
1==
$p
?
\$
$z
: 1/0)"
generatePlotScript
"
$t
"
../
$pf
"
$u
"
${
dataFiles
[
$i
]
}
>
$of
plotFiles+
=(
$of
)
done
done
}
function
generatePlotScriptsErrors
()
{
local
titles
=(
"RxFcsErrors"
"RxSeqErr"
"RxMisErr"
"RxPldErr"
"RxBer"
)
local
pngFiles
=(
rxFcsErrors rxSeqErr rxMisErr rxPldErr rxBer
)
local
tkIdxList
=(
$tkIdxRxFcsErrors
$tkIdxRxSeqErr
$tkIdxRxMisErr
$tkIdxRxPldErr
$tkIdxRxBer
)
local
dataFiles
=(
$dataFile
$dataFile
$dataFile
$dataFile
$dataFile
)
for
i
in
${
!titles[@]
}
;
do
tkIdx
=
${
tkIdxList
[
$i
]
}
# Latencies
pf
=
"
${
pngFiles
[
$i
]
}
"
of
=
"
$pf
.p"
z
=
$((
${
plotDataIdx
[
$tkIdx
]
}
+
1
))
# +1 because GNUPLOT indexes start at 1
generatePlotScript
"
${
titles
[
$i
]
}
"
../
$pf
2:3:
$z
${
dataFiles
[
$i
]
}
>
$of
if
[
"
${
valuesMax
[
$tkIdx
]
}
"
!=
"0"
]
;
then
plotFiles+
=(
$of
)
;
echo
"File
$of
will be plotted (valueMax=
${
valuesMax
[
$tkIdx
]
}
)"
fi
done
}
function
generatePlotScripts
()
{
rm
-f
*
.p
generatePlotScriptsLatencies
generatePlotScriptsErrors
generatePlotScriptsLimits
}
function
main
()
{
>
&2
echo
"Generate 3D plots"
#plotDataIdx=( [0]=0 [1]=1 [2]=2 [3]=3 [4]=4 [5]=5 [6]=6 [7]=7 [8]=8 [9]=9 [10]=10 )
#portCount=4
scanData
>
&2
echo
"Generate plot ..."
generatePlotScripts
>
&2
echo
"Generate Images ..."
generateImages
}
main
sw/xena-tester/tools/genLib.sh
0 → 100755
View file @
a84c07b1
dataFile
=
plot.dat
dataFileFilteredNoErrors
=
plot_no_errors.dat
dataFileLimits
=
plot_limits.dat
dataFileTransposed
=
plot_trp.dat
dbg
=
"1"
function
enum
()
{
local
-a
list
=(
"
${
!1
}
"
)
local
i
local
x
=
0
for
i
in
${
list
[@]
}
;
do
readonly
${
i
}
=
$((
x++
))
;
done
}
function
list
()
{
local
name
=
$1
local
-a
list
=(
"
${
!2
}
"
)
for
i
in
${
!list[@]
}
;
do
eval
"
${
name
}
[i]=
${
list
[
$i
]
}
"
done
}
configFile
=
config.txt
logName
=
""
cleanLogName
=
""
dataCollectionName
=
""
function
decodeConfig
()
{
local
line
=
""
while
read
line
;
do
if
[[
$line
=
[
a-zA-Z]
*
]]
;
then
OLDIFS
=
$IFS
IFS
=
"="
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
case
${
tokens
[0]
}
in
"logName"
)
logName
=
${
tokens
[1]
}
;;
"cleanLogName"
)
cleanLogName
=
${
tokens
[1]
}
;;
"dataCollectionName"
)
dataCollectionName
=
"
${
tokens
[1]
}
"
;;
esac
fi
done
<
$configFile
}
function
genInit
()
{
#Set default max values
for
tkIdx
in
${
tkIdxs
[@]
}
;
do
valuesMax[
$tkIdx
]=
${
valuesMax
[
$tkIdx
]--9999999999
}
done
decodeConfig
}
# Values max indexed by tkIdx...
declare
-a
valuesMax
# Column in Csv file indexed by tkIdx...
declare
-a
csvColumn
# Number of ports found
portCount
=
${
portCount
--1
}
# If exist do not overwrite it
# Token idx names
tkIdxNames
=(
tkIdxPort
tkIdxFrameLength
tkIdxNetLoad
tkIdxRxFcsErrors
tkIdxRxSeqErr
tkIdxRxMisErr
tkIdxRxPldErr
tkIdxRxBer
tkIdxLatencyAvg
tkIdxLatencyMin
tkIdxLatencyMax
)
# Create enumeration and list
enum tkIdxNames[@]
list tkIdxs tkIdxNames[@]
genInit
declare
-a
cvsTitles
=(
[
$tkIdxFrameLength
]=
"FrameLength"
[
$tkIdxNetLoad
]=
"NetLoad"
[
$tkIdxRxFcsErrors
]=
"RxFcsErrors"
[
tkIdxRxSeqErr]
=
"RxSeqErr"
[
tkIdxRxMisErr]
=
"RxMisErr"
[
tkIdxRxPldErr]
=
"RxPldErr"
[
tkIdxRxBer]
=
"RxBer"
[
tkIdxLatencyAvg]
=
"LatencyAvg"
[
tkIdxLatencyMin]
=
"LatencyMin"
[
tkIdxLatencyMax]
=
"LatencyMax"
[
tkIdxPort]
=
"SrcPort"
)
function
displayPercentage
()
{
local
maxValue
=
$1
local
currValue
=
$2
modulo
=
`
echo
"scale=0;
$currValue
%20"
| bc
`
if
[
"
${
modulo
}
"
==
"0"
]
;
then
p
=
`
echo
"scale=0; (
$currValue
*100)/
$maxValue
"
| bc
`
echo
-ne
"
\r
$p
%"
fi
}
>
&2
function
clearDisplayPercentage
()
{
echo
-ne
"
\r
\r
"
}
>
&2
# Gnluplot data index indexed by tkIdx.....
declare
-a
plotDataIdx
function
printArray
()
{
local
arr
=(
"
${
!1
}
"
)
local
ret
=
""
local
i
=
0
for
i
in
${
!arr[@]
}
;
do
ret+
=
"[
$i
]=
${
arr
[
$i
]
}
"
done
echo
-n
$ret
}
function
displayDebugInfo
()
{
if
[
-n
"
$dbg
"
]
;
then
echo
"portCount=
$portCount
"
echo
-n
"tkIdxs= "
;
echo
$(
printArray tkIdxs[@]]
)
echo
-n
"tkIdxNames: "
;
echo
$(
printArray tkIdxNames[@]]
)
echo
-n
"cvsTitles: "
;
echo
$(
printArray cvsTitles[@]]
)
echo
-n
"plotDataIdx: "
;
echo
$(
printArray plotDataIdx[@]]
)
echo
-n
"csvColumn: "
;
echo
$(
printArray csvColumn[@]]
)
echo
-n
"valuesMax: "
;
echo
$(
printArray valuesMax[@]]
)
echo
-n
"logName: "
;
echo
$logName
echo
-n
"cleanLogName: "
;
echo
$cleanLogName
echo
-n
"dataCollectionName: "
;
echo
$dataCollectionName
fi
}
>
&2
function
scanData
()
{
local
line
=
""
local
n
=
0
>
&2
echo
Scanning
$dataFile
...
if
[
"
$portCount
"
-eq
"-1"
]
;
then
local
lineCnt
=
`
wc
-l
$dataFile
|
grep
-o
^[0-9]
*
`
portCount
=
0
while
read
line
;
do
if
[[
$line
=
~ ^#.
*
]]
;
then
getDataPosition
"
$line
"
else
getDataOverview
"
$line
"
fi
n
=
$((
$n
+
1
))
displayPercentage
$lineCnt
$n
done
<
$dataFile
# Update port count
portCount
=
$((
${
valuesMax
[
$tkIdxPort
]
}
+
1
))
clearDisplayPercentage
fi
displayDebugInfo
}
function
getDataPosition
()
{
local
line
=
"
$1
"
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
local
token
=
0
local
i
=
0
for
token
in
${
tokens
[@]
}
;
do
if
[[
$token
=
~ ^[A-Za-z].
*
]]
;
then
local
j
=
0
for
j
in
${
!cvsTitles[@]
}
;
do
local
label
=
${
cvsTitles
[
$j
]
}
if
[
"
$label
"
==
"
$token
"
]
;
then
plotDataIdx[
$j
]=
$i
fi
done
i
=
$((
$i
+
1
))
fi
done
}
function
getDataOverview
()
{
local
line
=
"
$1
"
if
[[
$line
=
[
0-9-+]
*
]]
;
then
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
for
tkIdx
in
${
tkIdxs
[@]
}
;
do
local
idx
=
${
plotDataIdx
[
$tkIdx
]
}
local
value
=
${
tokens
[
$idx
]
}
if
((
$(
echo
"
$value
>
${
valuesMax
[
$tkIdx
]
}
"
|bc
-l
)
))
;
then
valuesMax[
$tkIdx
]=
$value
;
fi
done
fi
}
sw/xena-tester/tools/genTable.sh
0 → 100755
View file @
a84c07b1
#!/bin/bash
source
genLib.sh
function
texLimitTableOpen
()
{
local
caption
=
"
$1
"
echo
"
\\
begin{table}[!bp]"
echo
"
\\
centering"
echo
"
\\
begin{minipage}{0.85
\\
textheight}"
echo
"
\\
def
\\
arraystretch{0.9}"
echo
"
\\
small
\\
centering"
echo
"
\\
setlength{
\\
tabcolsep}{1.0mm}"
echo
"
\\
scriptsize"
echo
"
\\
centering"
echo
"
\\
caption{
$caption
}"
# echo " \\label{my-label}"
echo
"
\\
begin{tabular}{|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"}"
echo
"
\\
hline"
echo
"
\\
multirow{2}{*}{
\\
textbf{
\\
begin{tabular}[c]{@{}l@{}}Frm
\\\\
Size
\\
end{tabular}}}"
echo
"&
\\
multirow{2}{*}{
\\
textbf{
\\
begin{tabular}[c]{@{}l@{}}Net
\\\\
Ld
\\
end{tabular}}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxFcsErrors}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxSeqErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxMisErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxPldErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxBer}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyAvg (us)}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyMin (us)}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyMax (us)}}"
echo
"
\\\\
"
echo
"
\\
cline{3-34}"
echo
" & "
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
"
\\\\
"
echo
"
\\
hline"
}
function
texLimitTableClose
()
{
echo
"
\\
hline"
echo
"
\\
end{tabular}"
echo
"
\\
end{minipage}"
echo
"
\\
end{table}"
}
function
texFullTableOpen
()
{
local
caption
=
"
$1
"
echo
"
\\
begin{table}[!bp]"
echo
"
\\
centering"
echo
"
\\
rotatebox{90}{%"
echo
"
\\
begin{minipage}{0.85
\\
textheight}"
echo
"
\\
def
\\
arraystretch{0.9}"
echo
"
\\
small
\\
centering"
echo
"
\\
setlength{
\\
tabcolsep}{1.0mm}"
echo
"
\\
scriptsize"
echo
"
\\
centering"
echo
"
\\
caption{
$caption
}"
# echo " \\label{my-label}"
echo
"
\\
begin{tabular}{|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"r|r|r|r|"
echo
"}"
echo
"
\\
hline"
echo
"
\\
multirow{2}{*}{
\\
textbf{
\\
begin{tabular}[c]{@{}l@{}}Frm
\\\\
Size
\\
end{tabular}}}"
echo
"&
\\
multirow{2}{*}{
\\
textbf{
\\
begin{tabular}[c]{@{}l@{}}Net
\\\\
Ld
\\
end{tabular}}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxFcsErrors}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxSeqErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxMisErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxPldErr}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{RxBer}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyAvg (us)}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyMin (us)}}"
echo
"&
\\
multicolumn{4}{c|}{
\\
textbf{LatencyMax (us)}}"
echo
"
\\\\
"
echo
"
\\
cline{3-34}"
echo
" & "
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
" & P0 & P1 & P2 & P3"
echo
"
\\\\
"
echo
"
\\
hline"
}
function
texFullTableClose
()
{
echo
"
\\
hline"
echo
"
\\
end{tabular}"
echo
"
\\
end{minipage}"
echo
"}"
echo
"
\\
end{table}"
}
function
texFullTableRow
()
{
local
-a
rowData
=(
"
${
!1
}
"
)
for
rowIdx
in
${
!rowData[@]
}
;
do
if
[
"
$rowIdx
"
!=
"0"
]
;
then
echo
-n
" & "
;
fi
echo
-n
"
${
rowData
[
$rowIdx
]
}
"
done
echo
"
\\\\
"
}
MAX_ROW_PER_TABLE
=
50
function
transposeDataForFullTable
()
{
local
frmSize
=
0
local
netLoad
=
0
local
n
=
0
echo
>
$dataFileTransposed
local
lineCnt
=
`
wc
-l
$dataFile
|
grep
-o
^[0-9]
*
`
while
read
line
;
do
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
if
[[
${
tokens
[0]
}
=
[
0-3]
*
]]
;
then
port
=
${
tokens
[
${
plotDataIdx
[
$tkIdxPort
]
}
]
}
frmSize
=
${
tokens
[
${
plotDataIdx
[
$tkIdxFrameLength
]
}
]
}
netLoad
=
${
tokens
[
${
plotDataIdx
[
$tkIdxNetLoad
]
}
]
}
rxFcsErrors[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxRxFcsErrors
]
}
]
}
rxSeqErr[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxRxSeqErr
]
}
]
}
rxMisErr[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxRxMisErr
]
}
]
}
rxPldErr[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxRxPldErr
]
}
]
}
rxBer[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxRxBer
]
}
]
}
latencyAvg[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxLatencyAvg
]
}
]
}
latencyMin[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxLatencyMin
]
}
]
}
latencyMax[
$port
]=
${
tokens
[
${
plotDataIdx
[
$tkIdxLatencyMax
]
}
]
}
if
[
"
$port
"
-eq
"3"
]
;
then
str
=
"
$frmSize
$netLoad
"
for
i
in
`
seq
0 3
`
;
do
str+
=
"
${
rxFcsErrors
[
$i
]
}
"
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
"
${
rxSeqErr
[
$i
]
}
"
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
"
${
rxMisErr
[
$i
]
}
"
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
"
${
rxPldErr
[
$i
]
}
"
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
" "
;
str+
=
`
echo
"scale=2;
${
rxBer
[
$i
]
}
/1"
| bc
`
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
" "
;
str+
=
`
echo
"scale=1;
${
latencyAvg
[
$i
]
}
/1"
| bc
`
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
" "
;
str+
=
`
echo
"scale=1;
${
latencyMin
[
$i
]
}
/1"
| bc
`
;
done
for
i
in
`
seq
0 3
`
;
do
str+
=
" "
;
str+
=
`
echo
"scale=1;
${
latencyMax
[
$i
]
}
/1"
| bc
`
;
done
echo
$str
>>
$dataFileTransposed
fi
fi
n
=
$((
$n
+
1
))
displayPercentage
$lineCnt
$n
done
<
$dataFile
clearDisplayPercentage
}
function
generateTexFullTables
()
{
local
caption
=
"
$1
"
local
line
=
""
local
tableCount
=
1
local
rowCount
=
0
texFullTableOpen
"
$caption
- part
$tableCount
"
while
read
line
;
do
OLDIFS
=
$IFS
IFS
=
" "
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
if
[[
${
tokens
[0]
}
=
[
0-9]
*
]]
;
then
rowCount
=
$((
$rowCount
+
1
))
if
[
"
$rowCount
"
-gt
"
$MAX_ROW_PER_TABLE
"
]
;
then
texFullTableClose
tableCount
=
$((
$tableCount
+
1
))
texFullTableOpen
"
$caption
- part
$tableCount
"
rowCount
=
0
fi
texFullTableRow tokens[@]
fi
done
<
$dataFileTransposed
texFullTableClose
}
function
generateTexFullTable
()
{
>
&2
echo
" Transpose data ..."
transposeDataForFullTable
pf
=
"rawData"
of
=
"../
$pf
.tex"
rm
-f
$of
>
&2
echo
" Generating table
$of
"
generateTexFullTables
"
$dataCollectionName
"
>
$of
}
function
main
()
{
>
&2
echo
"Generate Latex tables"
scanData
#plotDataIdx=( [0]=0 [1]=1 [2]=2 [3]=3 [4]=4 [5]=5 [6]=6 [7]=7 [8]=8 [9]=9 [10]=10 )
generateTexFullTable
}
main
sw/xena-tester/tools/logCleaner.sh
0 → 100755
View file @
a84c07b1
#!/bin/bash
source
genLib.sh
tmpFile1
=
${
cleanLogName
}
_1.tmp
tmpFile2
=
${
cleanLogName
}
_2.tmp
#tmpFile=/dev/stdout
# Tx frame tag
txFrameMax
=
4200000
lastTxFrames
=(
0 0 0 0
)
streamLines
=(
""
""
""
""
)
streamSynchronized
=(
0 0 0 0
)
#list of columns
tkStream
=
1
tkTxFrames
=
6
function
learning
()
{
local
line
=
$1
local
tokens
OLDIFS
=
$IFS
IFS
=
","
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
for
i
in
"
${
!tokens[@]
}
"
;
do
if
[
"
${
tokens
[
$i
]
}
"
==
"TxFrames"
]
;
then
tkTxFrames
=
$i
break
fi
done
}
function
formatHeader
()
{
local
line
=
$1
s
=
${
line
/Timestamp/
'Timestamp,FrameLength,NetLoad'
}
echo
$s
}
function
formatData
()
{
local
line
=
$1
OLDIFS
=
$IFS
IFS
=
",
\n
"
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
local
txFrames
=
${
tokens
[
$tkTxFrames
]
}
local
netLoad
=
`
echo
"scale=0;
$txFrames
%100"
| bc
`
local
subFrameLength
=
0
if
[
"
$netLoad
"
-eq
"0"
]
;
then
subFrameLength
=
1
netLoad
=
100
fi
local
frameLength
=
`
echo
"scale=0; (
$txFrames
%1000000)/100-
$subFrameLength
"
| bc
`
local
ret
=
"
${
tokens
[0]
}
,"
ret+
=
"
$frameLength
,"
ret+
=
"
$netLoad
,"
local
i
=
0
for
value
in
${
tokens
[@]
:1
}
;
do
if
[
"
$i
"
-gt
"0"
]
;
then
ret+
=
","
;
fi
ret+
=
"
$value
"
i
=
$((
$i
+
1
))
done
echo
"
$ret
"
}
function
getStreamIndex
()
{
local
stream
=
$1
echo
`
echo
$stream
|
grep
-o
-e
"[0-9]*$"
`
}
function
lineDecoder
()
{
local
line
=
$1
local
tokens
OLDIFS
=
$IFS
IFS
=
","
read
-a
tokens
<<<
"
$(
echo
$line
)
"
IFS
=
$OLDIFS
local
streamId
=
$(
getStreamIndex
${
tokens
[
$tkStream
]
}
)
local
txFrames
=
${
tokens
[
$tkTxFrames
]
}
if
[
-z
"
$txFrames
"
]
;
then return
0
;
fi
if
[
"
$txFrames
"
-gt
"
${
txFrameMax
}
"
]
;
then return
0
;
fi
if
[
"
$txFrames
"
-lt
"
${
lastTxFrames
[
$streamId
]
}
"
]
;
then
formatData
"
${
streamLines
[
$streamId
]
}
"
fi
lastTxFrames[
$streamId
]=
$txFrames
streamLines[
$streamId
]=
"
$line
"
}
## main
function
main
()
{
local
n
=
1
local
lineCnt
=
`
wc
-l
$logName
|
grep
-o
^[0-9]
*
`
sed
-i
"1s/,Port,/,SrcPort,/"
$logName
# Change Port in the header by SrcPort
while
read
line
;
do
if
[
"
$n
"
-eq
"1"
]
;
then
learning
$line
formatHeader
"
$line
"
else if
[
"
$n
"
-gt
"2"
]
;
then
lineDecoder
"
$line
"
fi
fi
n
=
$((
n+1
))
#if [ "$n" -gt "10000" ] ; then break; fi
displayPercentage
$lineCnt
$n
done
<
$logName
clearDisplayPercentage
}
main
>
$tmpFile1
cat
$tmpFile1
|
sed
-e
"s/
\r
//g"
|
sed
's/[,]$//'
>
$tmpFile2
(
head
-n
1
$tmpFile2
&&
tail
-n
+2
$tmpFile2
|
sort
-t
$','
-k
1,1
-k
2,2
-k
3,3
-k
4,4
)
>
$cleanLogName
rm
-f
*
.tmp
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment