aboutsummaryrefslogtreecommitdiff
path: root/run/benchmark
blob: 7587ff47e738e091552a71a3a0f9864a5e495254 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;

my @cmd = (
	q{date},
	q{perl -le 'print "Hello world!"'},
	q{python -c 'print("Hello world!")'},
	q{ruby -le 'print "Hello world!"'},
);

if (-f 'cfg/benchmark') {
	open my $cfg, '<', 'cfg/benchmark'
		or die "Could not open < cfg/benchmark: $!";
	no strict; no warnings;
	eval do {local $/; <$cfg>};
	die if $@;
	close $cfg;
}

my @res;
for (1..3) {
	@res = ();
	for (reverse @cmd) {
		(my $q = $_) =~ s/'/'"'"'/g;
		push @res, "\$ time $_\n" . `bash -c 'time $q' 2>&1`;
	}
}
print join("\n", reverse @res);