-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_benchmark.pl
50 lines (43 loc) · 1.44 KB
/
extract_benchmark.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/perl
use strict;
use warnings;
my @files = @ARGV;
my $total_throughput = 0;
my $count = 0;
sub usage() {
print STDERR "Usage: \$perl extract_benchmark.pl <log_files...>\n"
}
if (@ARGV == 0 && -t STDIN && -t STDERR) {
usage();
exit();
}
foreach my $file (@files) {
open(my $fh, '<', $file) or die "Cannot open file $file: $!";
while (my $line = <$fh>) {
if ($line =~ /RuntimeError: ([\w\s]+)/) {
print("File $count: RuntimeError: $1\n");
last;
}
if ($line =~ /Throughput per token including tokenize: ([\d.]+) msecs/) {
$count++;
print "File $count: Throughput per token including tokenize: ", $1, " msecs\n";
$total_throughput += $1;
}
elsif ($line =~ /Start to ready to generate: ([\d.]+) secs/) {
print "File $count: Start to ready to generate: ", $1, " secs\n";
}
elsif ($line =~ /Tokenize and generate (\d+) \(bs=\d+\) tokens: ([\d.]+) secs/) {
print "File $count: Tokenize and generate $1 tokens: ", $2, " secs\n";
}
elsif ($line =~ /Start to finish: ([\d.]+) secs/) {
print "File $count: Start to finish: ", $1, " secs\n";
}
}
close($fh);
}
print "***\n";
if ($count > 0) {
print "Average Throughput per token including tokenize: ", $total_throughput / $count, " msecs\n";
} else {
print "No performance stats found in the provided files.\n";
}