File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,13 @@ for @CHANNELS -> $channel {
46
46
}
47
47
}
48
48
49
+ my num $ jsontime = 0e0 ;
50
+ my num $ totaltime = 0e0 ;
51
+
52
+ my num $ starttime = now. Num ;
53
+
54
+ my @ json_errors ;
55
+
49
56
note ‘ Caching…’ ;
50
57
for @ CHANNELS {
51
58
my @ msgs ;
@@ -55,7 +62,12 @@ for @CHANNELS {
55
62
. note ;
56
63
my $ date = . basename ;
57
64
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 {
59
71
next without . [1 ];
60
72
@ msgs . push : (
61
73
. [3 ], # what
@@ -66,10 +78,17 @@ for @CHANNELS {
66
78
). join : “ \0” ;
67
79
$ total ++
68
80
}
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 } }
70
82
}
71
83
}
72
84
note “ Loaded $ total messages” ;
73
85
spurt $ channel-dir ~ ‘ .total’ , $ total ;
74
86
spurt $ channel-dir ~ ‘ .cache’ , @ msgs . join : “ \0\0”
75
87
}
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 } " ;
You can’t perform that action at this time.
0 commit comments