-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbenchmark.pl6
50 lines (45 loc) · 1.39 KB
/
benchmark.pl6
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
use v6;
need JsonC;
use JSON::Fast;
# An speed test.
my $JSON = "$*HOME/.zef/store/projects1.json";
if $JSON.IO.e {
with $JSON {
say "Testing with $_ ({$_.IO.s})";
say "Trying to read with JsonC (raw):";
{
my $start = now;
my @a := JsonC::JSON.new-from-file($_);
say "Last module is '{@a[@a.elems-1]<description>}";
say "Parsed in { now - $start }s. @a.elems() projects";
my $s1 = now;
my %b = @a.first({$_<name> eq 'DBIish'});
say "DBDish '%b<description>' located in { now - $s1 }s";
say "Total time: { now - $start }";
}
say "---";
say "Trying to read with JsonC (unmarshaled):";
{
my $start = now;
my @a := JsonC::JSON.new-from-file($_).Perl;
say "Last module is '{@a[@a.elems-1]<description>}";
say "Parsed in { now - $start }s. @a.elems() projects";
my $s1 = now;
my %b = @a.first({$_<name> eq 'DBIish'});
say "DBDish '%b<description>' located in { now - $s1 }s";
say "Total time: { now - $start }";
}
say "---";
say "Trying to read with JSON::Fast";
{
my $start = now;
my @a := from-json($_.IO.slurp);
say "Last module is '{@a[@a.elems-1]<description>}";
say "Parsed in { now - $start }s. @a.elems() projects";
my $s1 = now;
my %b = @a.first({$_<name> eq 'DBIish'});
say "DBDish '%b<description>' located in { now - $s1 }s";
say "Total time: { now - $start }";
}
}
}