From 3aecdb97ef7c3c7588481ef9b3bb15b9f8ab891c Mon Sep 17 00:00:00 2001 From: Javier Gusano Martinez Date: Wed, 17 Jun 2015 16:34:26 +0200 Subject: [PATCH 1/5] Readme files for statistics tools. --- README.md | 9 ++++++++- analysis/README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 analysis/README.md diff --git a/README.md b/README.md index 11411de..34389d7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This repository contains all necessary for deploy HTTP/2 testing server or clien ## Version -0.3.0 +0.4.0 ## Installation @@ -32,6 +32,13 @@ This repository is organized under directories according with the content: ``` / | +├───analysis/ # Scripts to calculate statistical parameters with the tests results. +| │ README.md # This file contains info about how to use these tools. +| | +| ├───data/ # Test results output files. +| | +| └───mean/ # Files with cumulative mean for each test samples. +| ├───clients/ # Testing clients installation. | | README.md # This file contains info about how to use the installation scripts. | | diff --git a/analysis/README.md b/analysis/README.md new file mode 100644 index 0000000..8b91274 --- /dev/null +++ b/analysis/README.md @@ -0,0 +1,43 @@ +# HTTP/2 Test Reults Analysis + +This tools provides an easy way to get statistical parameters using test results files. By the moment these are the calculated parameters: + +- **Cumulative Mean:** Evolution of the mean value along each test sample result. Used to view the mean stabilisation of value along the time. +- **Mean:** Last value of cumulative mean evolution. +- **Typical deviation.** + + +## How to use? + +You must follow the following steps: + +1. Launch the installation script if it's the first time that you are using this tool. +2. Put all test results files inside "data" directory. +3. Launch the cumulative mean calculator script. +4. Launch the statistical parameters calculator. The calculated values are shown under standard output. + +### Installation script: + +This tool is used to make the basic directory structure for the statistics tools. Run it only if it's the first time that you are using this tool: + +```sh +$ python install.sh +``` + +### Cumulative mean calculator: + +This script should be executed with the following command: + +```sh +$ python cumulat_mean.py +``` + +The output files are stored under "mean" directory with its graph representation. + +### Statistical parameters calculator: + +This script should be executed with the following command: + +```sh +$ python statistics.py +``` \ No newline at end of file From ea910591cef83161f28b21cfaa55f90acf1694d7 Mon Sep 17 00:00:00 2001 From: Javier Gusano Martinez Date: Wed, 17 Jun 2015 16:38:24 +0200 Subject: [PATCH 2/5] Fixed error on analysis/README.md file. --- analysis/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/analysis/README.md b/analysis/README.md index 8b91274..d1a9461 100644 --- a/analysis/README.md +++ b/analysis/README.md @@ -18,10 +18,10 @@ You must follow the following steps: ### Installation script: -This tool is used to make the basic directory structure for the statistics tools. Run it only if it's the first time that you are using this tool: +This tool is used to make the basic directory structure for the statistics tools. Run it only if it's the first time that you are using this tool. ```sh -$ python install.sh +$ ./install.sh ``` ### Cumulative mean calculator: @@ -40,4 +40,4 @@ This script should be executed with the following command: ```sh $ python statistics.py -``` \ No newline at end of file +``` From 298375fc55bdc600906e10d8a3ae74301f21cfef Mon Sep 17 00:00:00 2001 From: Javier Gusano Martinez Date: Wed, 17 Jun 2015 16:42:30 +0200 Subject: [PATCH 3/5] Installation script for Statistical Analysis. --- .gitignore | 4 ++++ analysis/install.sh | 3 +++ 2 files changed, 7 insertions(+) create mode 100755 analysis/install.sh diff --git a/.gitignore b/.gitignore index 3fac907..8254f2d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,10 @@ Makefile.in # Test results directory /scripts/results +# Statistics analysis directories +/analysis/data +/analysis/mean + # Created by https://www.gitignore.io ### Linux ### diff --git a/analysis/install.sh b/analysis/install.sh new file mode 100755 index 0000000..821434b --- /dev/null +++ b/analysis/install.sh @@ -0,0 +1,3 @@ +#!/bin/bash +mkdir -p data +mkdir -p mean From 82cded863a58137bfbe3ac4981cf0e7c12423520 Mon Sep 17 00:00:00 2001 From: Javier Gusano Martinez Date: Wed, 17 Jun 2015 17:09:14 +0200 Subject: [PATCH 4/5] New scripts for statistical parameters. --- analysis/README.md | 2 +- analysis/calculator.py | 32 ++++++++++++++++++++++++++++++++ analysis/cumulat_mean.sh | 31 +++++++++++++++++++++++++++++++ analysis/statistics.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 analysis/calculator.py create mode 100644 analysis/cumulat_mean.sh create mode 100644 analysis/statistics.py diff --git a/analysis/README.md b/analysis/README.md index d1a9461..c0c553e 100644 --- a/analysis/README.md +++ b/analysis/README.md @@ -29,7 +29,7 @@ $ ./install.sh This script should be executed with the following command: ```sh -$ python cumulat_mean.py +$ ./cumulat_mean.sh ``` The output files are stored under "mean" directory with its graph representation. diff --git a/analysis/calculator.py b/analysis/calculator.py new file mode 100755 index 0000000..6e0e097 --- /dev/null +++ b/analysis/calculator.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import glob +# Reading all *.dat filenames with the tests time values +files = glob.glob("data/*.dat") +# Loading files and processing data +i = 1 +for datafile in files: + print ('Current filename ' + str(i) + ': ' + datafile) + i += 1 + f = open(datafile + '_mean.mdat', 'w') # Calculated values of mean + # Creating local variables for statistics + index = 1 # Storage the index of the value + currentValue = 0 # Value read from the file + previousValue = 0 # Value read from the previous iteration + mean = 0 # Contains the mean cumulative + for fileLine in open(datafile): + currentVal = float(fileLine) + if index > 1: + if index > 2: + print('Index greather than 2') + mean = (mean * (index - 1) + currentVal) / index + else: + print('Index equal than 2') + mean = (currentVal + previousValue) / index + print ('Mean value: ' + str(mean)) + f.write(str(mean)+'\n') + else: + print('Readed first value from file...') + # Preparing variables for the next iteration + previousValue = currentVal + index += 1 +print 'End calculator' diff --git a/analysis/cumulat_mean.sh b/analysis/cumulat_mean.sh new file mode 100644 index 0000000..2c92059 --- /dev/null +++ b/analysis/cumulat_mean.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +echo "***************************************************" +echo "* Calculating data files *" +echo "***************************************************" +python calculator.py +cp *.mdat mean/ +rm *.mdat +FILES_TO_PLOT=$(find mean/ -type f) +echo "Done!" + +echo "***************************************************" +echo "* Drawing files... *" +echo "***************************************************" +for COMMAND in $FILES_TO_PLOT +do + echo "File to graph:" + echo $COMMAND + # Saving result to $FILENAME external file: + testPage=$(echo $COMMAND | awk -F[/] '{print $2}') + FILENAME_GRAPH="${testPage}_${NUMBERTESTS}_mgraph.png" + echo $FILENAME_GRAPH + gnuplot -e "set term png; plot '$COMMAND' w l; set output 'graph.png'; replot;" + cp graph.png mean/$FILENAME_GRAPH + rm graph.png +done + +echo "===============================================" +echo " DONE! ALL GRAPHS HAS BEEN CREATED SUSCESFULLY!" +echo "===============================================" diff --git a/analysis/statistics.py b/analysis/statistics.py new file mode 100644 index 0000000..ea23f65 --- /dev/null +++ b/analysis/statistics.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# This tool provides an automatic way to get basic statistic values as: Mean value and Standar deviation +# The mean data files should be inside "data" directory and "mean" for each file shoud be inside "mean" directory. +# +# +import glob +import os +import math +# Reading all *.dat filenames with the tests time values +files = glob.glob("data/*.dat") +# Loading files and processing data +n = 0 +for datafile in files: + # Reading last value of accumulated mean for the curren test + fshell = os.popen('tail -n 1 mean/' + os.path.basename(datafile) + '_mean.mdat') + meanValue = float(fshell.read()) / 1000 # Parsing units us to ms. + ## Creating local variables for statistics + sumatoryValue = 0 # Contains the result of the summatory used for calc Standard deviation + n = 0 # Number of statistical samples storaged in to .dat file. + for fileLine in open(datafile): + fileLine = float(fileLine) / 1000 # Parsing units us to ms. + sumatoryValue = sumatoryValue + math.pow(fileLine-meanValue, 2) + #print str(sumatoryValue) + n += 1 + # Calculate Standard deviation + sDeviation = math.sqrt((1 / float(n)) * sumatoryValue) + print ('- Current filename: ' + os.path.basename(datafile) + '\tMean value: ' + str(meanValue) + '\tStandar Deviation: ' + str(sDeviation)) +print 'End calculator' From a4b4ec8c77bd3a8b173dd626ec073c457ee952c9 Mon Sep 17 00:00:00 2001 From: Javier Gusano Martinez Date: Wed, 17 Jun 2015 17:18:46 +0200 Subject: [PATCH 5/5] Fixed errors on cumulat_mean.sh and install.sh scripts. --- analysis/cumulat_mean.sh | 4 ++-- analysis/install.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) mode change 100644 => 100755 analysis/cumulat_mean.sh diff --git a/analysis/cumulat_mean.sh b/analysis/cumulat_mean.sh old mode 100644 new mode 100755 index 2c92059..6c5a91b --- a/analysis/cumulat_mean.sh +++ b/analysis/cumulat_mean.sh @@ -5,8 +5,8 @@ echo "***************************************************" echo "* Calculating data files *" echo "***************************************************" python calculator.py -cp *.mdat mean/ -rm *.mdat +cp data/*.mdat mean/ +rm data/*.mdat FILES_TO_PLOT=$(find mean/ -type f) echo "Done!" diff --git a/analysis/install.sh b/analysis/install.sh index 821434b..48413c1 100755 --- a/analysis/install.sh +++ b/analysis/install.sh @@ -1,3 +1,5 @@ #!/bin/bash +sudo apt-get install gnuplot -y + mkdir -p data mkdir -p mean