Created
August 24, 2016 15:49
-
-
Save anonymous/d174b1677499edc6838a05ebf1b1fb9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/Rakudo/Internals/JSON.pm b/src/core/Rakudo/Internals/JSON.pm | |
index d8ae999..eaa9b69 100644 | |
--- a/src/core/Rakudo/Internals/JSON.pm | |
+++ b/src/core/Rakudo/Internals/JSON.pm | |
@@ -6,6 +6,9 @@ my class JSONException is Exception { | |
} | |
} | |
+my $total_time = 0e0; | |
+my %cache; | |
+ | |
my class Rakudo::Internals::JSON { | |
my class JSONPrettyActions { | |
method TOP($/) { | |
@@ -126,9 +129,21 @@ my class Rakudo::Internals::JSON { | |
} | |
method from-json($text) { | |
+ note $text.perl; | |
+ if %cache{$text}:exists { | |
+ note "already in cache." | |
+ } | |
+ else { | |
+ %cache{$text} = 1; | |
+ } | |
+ my $start = now; | |
my $a = JSONPrettyActions.new(); | |
my $o = JSONPrettyGrammar.parse($text, :actions($a)); | |
JSONException.new(:$text).throw unless $o; | |
+ my $took = now - $start; | |
+ note "--" if $total_time == 0e0; | |
+ $total_time = $total_time + $took; | |
+ note "json parse took { now - $start }s - $total_time"; | |
$o.ast; | |
} | |
method to-json(|c) { to-json(|c) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment