From c1a1d0022d98bc1d3b274fa3598814686fda566a Mon Sep 17 00:00:00 2001 From: P2P-Next User Date: Fri, 12 Nov 2010 17:05:32 +0200 Subject: [PATCH] Utils: tsup statistical scrips added --- Utils/avg2 | 22 ++++++++++++++++++++++ Utils/get_time_dl_speed_avg | 23 +++++++++++++++++++++++ Utils/get_time_dl_speed_avg_for_swarm | 22 ++++++++++++++++++++++ Utils/publish_time_dl_speed | 1 + 4 files changed, 68 insertions(+) create mode 100755 Utils/avg2 create mode 100755 Utils/get_time_dl_speed_avg create mode 100755 Utils/get_time_dl_speed_avg_for_swarm create mode 100755 Utils/publish_time_dl_speed diff --git a/Utils/avg2 b/Utils/avg2 new file mode 100755 index 0000000..d9c0346 --- /dev/null +++ b/Utils/avg2 @@ -0,0 +1,22 @@ +#!/usr/bin/awk -f +# Calculates the average value of 2 columns. Lines with the first column 0 are not taken into account. + +BEGIN { + n_items = 0 + sum1 = 0.0 + sum2 = 0.0 + FS = "[ \t]+" +} + +/^[0-9]+/ { + if($1 != 0) + { + n_items++ + sum1 += $1 + sum2 += $2 + } +} + +END { + printf "%f %f\n", sum1 / n_items, sum2 / n_items +} diff --git a/Utils/get_time_dl_speed_avg b/Utils/get_time_dl_speed_avg new file mode 100755 index 0000000..ee0c4f2 --- /dev/null +++ b/Utils/get_time_dl_speed_avg @@ -0,0 +1,23 @@ +#!/usr/bin/awk -f +# Calculates the download time and the average download speed in this time for a peer, printed in this order. The input is the *.log.data file content of the peer. + +BEGIN { + n_items = 0 + dl_speed_sum = 0.0 + done = 0 + FS = "[ \t]+" +} + +/^[0-9]+/ { + if($2 != 100 || $2 == 100 && done == 0) + { + n_items++ + dl_speed_sum += $4 + } + if($2 == 100) + done = 1 +} + +END { + printf "%d %f\n", n_items-1, dl_speed_sum / n_items +} diff --git a/Utils/get_time_dl_speed_avg_for_swarm b/Utils/get_time_dl_speed_avg_for_swarm new file mode 100755 index 0000000..20f6beb --- /dev/null +++ b/Utils/get_time_dl_speed_avg_for_swarm @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copyright: Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com +# +# This script calculates the download time and the average download speed for an entire swarm, printed in this order and taking as input the directory where the peers' *.log.data file are located. Requires script avg2 and get_time_dl_speed_avg. + +path=. + +if [ $# -gt 0 ]; then + path=$1 +fi + +rm -f temp1987 +touch temp1987 + +for i in $(find $path -mindepth 1 -mindepth 1 -name '*.log.data'); do + (./get_time_dl_speed_avg < "$i") >> temp1987 +done + +./avg2 < temp1987 + +rm -f temp1987 diff --git a/Utils/publish_time_dl_speed b/Utils/publish_time_dl_speed new file mode 100755 index 0000000..f802305 --- /dev/null +++ b/Utils/publish_time_dl_speed @@ -0,0 +1 @@ +for i in $(find ../Results/tsup-1t-2-2010.11.11-08.20.53/ -mindepth 1 -mindepth 1 -type d); do ./get_time_dl_speed_avg_for_swarm $i > $i/time_dl_speed_avg.data; done -- 2.20.1