Skip to content

Commit e53c688

Browse files
timoAlexDaniel
authored andcommitted
Add timings and debug info to fetch-irc script
1 parent 8bf0be4 commit e53c688

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

maintenance/fetch-irc.p6

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ for @CHANNELS -> $channel {
4646
}
4747
}
4848

49+
my num $jsontime = 0e0;
50+
my num $totaltime = 0e0;
51+
52+
my num $starttime = now.Num;
53+
54+
my @json_errors;
55+
4956
note Caching…;
5057
for @CHANNELS {
5158
my @msgs;
@@ -55,7 +62,12 @@ for @CHANNELS {
5562
.note;
5663
my $date = .basename;
5764
try {
58-
for from-json(slurp $_)<rows>.list {
65+
my str $source = slurp $_;
66+
my num $start = now.Num;
67+
my $jsondata = from-json($source)<rows>;
68+
$jsontime += now.Num - $start;
69+
70+
for $jsondata.list {
5971
next without .[1];
6072
@msgs.push: (
6173
.[3], # what
@@ -66,10 +78,17 @@ for @CHANNELS {
6678
).join: \0;
6779
$total++
6880
}
69-
CATCH { default { note Skipping $date because of JSON issues $_ } }
81+
CATCH { default { note Skipping $date because of JSON issues $_; @json_errors.push: $date.Str => $_.message } }
7082
}
7183
}
7284
note Loaded $total messages;
7385
spurt $channel-dir ~ .total, $total;
7486
spurt $channel-dir ~ .cache, @msgs.join: \0\0
7587
}
88+
$totaltime = now.Num - $starttime;
89+
90+
try spurt "fetch-irc-json-errors.err", @json_errors.fmt: "%s: %s", "\n";
91+
92+
say "total time spent caching: $totaltime";
93+
say "total time spent json decoding: $jsontime";
94+
say "ratio: { $jsontime / $totaltime }";

0 commit comments

Comments
 (0)