Skip to content

Commit

Permalink
Add stat.pl script
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Nov 11, 2023
1 parent 71075ed commit f0070b5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions stat.pl
Original file line number Diff line number Diff line change
@@ -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]);

0 comments on commit f0070b5

Please sign in to comment.