Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm1986 committed Jun 17, 2015
2 parents 148f8d7 + a4b4ec8 commit 6fa17d2
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
| |
Expand Down
43 changes: 43 additions & 0 deletions analysis/README.md
Original file line number Diff line number Diff line change
@@ -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
$ ./install.sh
```

### Cumulative mean calculator:

This script should be executed with the following command:

```sh
$ ./cumulat_mean.sh
```

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
```
32 changes: 32 additions & 0 deletions analysis/calculator.py
Original file line number Diff line number Diff line change
@@ -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'
31 changes: 31 additions & 0 deletions analysis/cumulat_mean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

echo "***************************************************"
echo "* Calculating data files *"
echo "***************************************************"
python calculator.py
cp data/*.mdat mean/
rm data/*.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 "==============================================="
5 changes: 5 additions & 0 deletions analysis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
sudo apt-get install gnuplot -y

mkdir -p data
mkdir -p mean
28 changes: 28 additions & 0 deletions analysis/statistics.py
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 6fa17d2

Please sign in to comment.