diff --git a/README.md b/README.md index 44c4af3..230da3c 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,19 @@ $ env/bin/python -m pingpong >out.csv ## Process the results -Install [Matplotlib](https://matplotlib.org/) to plot the results +There is a `stat.pl` Perl script analyzing the output file printing basic statistics, +for example: +``` +$ ./stat.pl out.csv +min: 1.12097477912903 +p05: 1.12548685073853 +median: 1.14409327507019 +p95: 1.20510101318359 +max: 1.22065734863281 +``` + +If you want to visualize the data, +install [Matplotlib](https://matplotlib.org/) to plot the results and [pandas](https://pandas.pydata.org/) to process the collected data: ``` . env/bin/activate diff --git a/stat.pl b/stat.pl new file mode 100755 index 0000000..e785526 --- /dev/null +++ b/stat.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +use v5.30; +use strict; +use warnings; + +my $file = $ARGV[0] or die "Missing command line argument\n"; +open(my $data, '<', $file) or die "Could not open '$file'\n"; +my $prev; +my @values = (); +while (my $line = <$data>) { + chomp $line; + my @fields = split "," , $line; + if (defined $prev) { + push(@values, $fields[1] - $prev) + } + $prev = $fields[1] +} +@values = sort @values; +say "min: " . ($values[0]); +say "p05: " . ($values[int($#values * 5 / 100)]); +say "median: " . ($values[int($#values / 2)]); +say "p95: " . ($values[int($#values * 95 / 100)]); +say "max: " . ($values[-1]);