http_compression004075500017500001750000000000001117367143400124405ustar00henryhttp_compression/bench.sh010075500017500001750000000010521117367061500141300ustar00henry#!/bin/sh if [ -z "$1" ] then echo "Usage: ${0} URL" exit 1 fi function bench { curl -s -o /dev/null \ --user-agent 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20' \ -w '%{time_total} %{time_connect} %{time_starttransfer} %{size_download}\n' \ $* } results_dir=. rm -f *.csv for i in 0 1 2 3 4 5 6 7 8 9; do for j in 0 1 2 3 4 5 6 7 8 9; do bench "$*" >> ${results_dir}/no\ gzip.csv bench --compress "$*" >> ${results_dir}/gzip.csv done done http_compression/report.py010075500017500001750000000046411117367113400144060ustar00henry#!/usr/bin/env python import os import math # Change this to True to get a HTML table _HTML_REPORT = False def _time(x): return '%d' % (x * 1000) def _mean(index, seq): return sum(float(r[index]) for r in seq) / len(seq) def _median(index, seq): return sorted(float(r[index]) for r in seq)[len(seq) // 2 + 1] def _standard_deviation(index, seq): mean = _mean(index, seq) diffs = list(pow(float(r[index]) - mean, 2) for r in seq) return math.sqrt(sum(diffs) / len(seq)) def report(filename): results = list(line.split() for line in open(filename)) if _HTML_REPORT: print '\n%s' % os.path.splitext(filename)[0] def _report(variable_name, index, dark): r = (_time(_mean(index, results)), _time(_median(index, results))) if dark: print '%s%s' % r else: print '%s%s' % r else: print filename def _report(variable_name, index, dark): print ' %s' % variable_name print ' Mean', _time(_mean(index, results)) print ' Median', _time(_median(index, results)) print ' Standard Deviation', _time(_standard_deviation(index, results)) print _report('Connect time', 1, True) _report('Pre-transfer time', 2, False) _report('Total time', 0, True) size = int(results[0][3]) if _HTML_REPORT: print '%d%.02f' % (size, float(size) / 1024) print '' else: print ' Size %d (%.02f KBytes)' % (size, float(size) / 1024) if _HTML_REPORT: print '' print ('' '' '' '' '' '' '') print ('' '' '' '' '' '') for filename in os.listdir('.'): if filename.endswith('.csv'): report(filename) if _HTML_REPORT: print '
FileConnect timePre-transfer timeTotal timeTransfert size
MeanMedianMeanMedianMeanMedianBytesKBytes
'