From 4f170523f0ab68a02892cc9d8c9beff78a4d3eb9 Mon Sep 17 00:00:00 2001 From: molsonkiko <46202915+molsonkiko@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:24:58 -0800 Subject: [PATCH] add python-style # comments to remespath --- CHANGELOG.md | 3 + .../JSONTools/RemesPathLexer.cs | 6 +- JsonToolsNppPlugin/Properties/AssemblyInfo.cs | 4 +- JsonToolsNppPlugin/Tests/RemesPathTests.cs | 18 +++- docs/RemesPath.md | 15 +++- most recent errors.txt | 86 +++++++++---------- 6 files changed, 80 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f4f428..4b18990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * maybe only try to do this for files with the `.csv` and `.tsv` extensions * only test the `,` and `\t` delimiters, and only the `"` or `'` quote characters * test only the first 10KB of the file, or first 25 lines, whichever comes first. +8. Unit tests that randomly generate text with JSON chars to make sure JSON parser never throws for any reason, since errors aren't caught. ### To Be Changed @@ -39,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### To Be Fixed +- Fix issue where pretty-printing or compressing causes tree view position tracking to be out of sync with the document until a query is issued or the `Refresh` button is hit. - Improve Alt-key accelerators *in forms*. They don't seem to work right for some reason. - When a tree viewer is refreshed using JSON from a file with a different name, the title of the docking form that the user sees doesn't change to reflect the new file. For example, a tree viewer is opened up for `foo.json` and then refreshed with a buffer named `bar.json`, and the title of the docking form still reads `Json Tree View for foo.json`. - This is also true if a file with a tree viewer is renamed, e.g., the file `foo.json` is renamed to `bar.json`, but the tree viewer still says `Json Tree View for foo.json`. @@ -56,6 +58,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). 1. A [RemesPath user-defined language (UDL) file](/RemesPath%20UDL.xml), providing some very basic syntax highlighting. It is buggy, but that is because the UDL system is inherently buggy, not because I did anything wrong (as far as I know). 2. Add [`and` and `or` non-vectorized functions in RemesPath](/docs/RemesPath.md#non-vectorized-functions), which both use conditional excution. 3. [PPrint-style pretty-printing that remembers comments](/docs/README.md#remember_comments) +4. [Python-style single-line comments in RemesPath](/docs/RemesPath.md#comments-added-in-v62) ### Changed diff --git a/JsonToolsNppPlugin/JSONTools/RemesPathLexer.cs b/JsonToolsNppPlugin/JSONTools/RemesPathLexer.cs index 017792f..17f23b1 100644 --- a/JsonToolsNppPlugin/JSONTools/RemesPathLexer.cs +++ b/JsonToolsNppPlugin/JSONTools/RemesPathLexer.cs @@ -79,6 +79,7 @@ public RemesPathLexer() @"([,\[\]\(\)\{\}\.:=!;])|" + // delimiters @"([gjf]?(? Tokenize(string q) toks.Add(new JNode(enquoted)); break; case 11: toks.Add(ParseUnquotedString(m.Value)); break; + case 12: /* toks.Add(new Comment(m.Value, false, m.Index)); */ break; // comments; currently we won't add them to the tokens, but maybe later? default: - throw new RemesLexerException($"Invalid token \"{m.Value}\" at position {m.Index}"); + throw new RemesLexerException(m.Index, q, $"Invalid token \"{m.Value}\""); } } BraceMatchCheck(q, regtoks, toks, '(', ')'); @@ -254,7 +256,7 @@ public static void BraceMatchCheck(string q, MatchCollection regtoks, List= MAX_RECURSION_DEPTH) - throw new RemesLexerException($"Maximum recuresion depth ({MAX_RECURSION_DEPTH}) in a RemesPath query reached"); + throw new RemesLexerException(regtoks[regTokIndex].Index, q, $"Maximum recursion depth ({MAX_RECURSION_DEPTH}) in a RemesPath query reached"); else if (unclosedCount == 1) lastUnclosed = regtoks[regTokIndex].Index; } diff --git a/JsonToolsNppPlugin/Properties/AssemblyInfo.cs b/JsonToolsNppPlugin/Properties/AssemblyInfo.cs index b80b06e..60f6116 100644 --- a/JsonToolsNppPlugin/Properties/AssemblyInfo.cs +++ b/JsonToolsNppPlugin/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("6.1.1.12")] -[assembly: AssemblyFileVersion("6.1.1.12")] +[assembly: AssemblyVersion("6.1.1.13")] +[assembly: AssemblyFileVersion("6.1.1.13")] diff --git a/JsonToolsNppPlugin/Tests/RemesPathTests.cs b/JsonToolsNppPlugin/Tests/RemesPathTests.cs index f70b0f0..a92fbd1 100644 --- a/JsonToolsNppPlugin/Tests/RemesPathTests.cs +++ b/JsonToolsNppPlugin/Tests/RemesPathTests.cs @@ -457,8 +457,15 @@ public static bool Test() // parens tests new Query_DesiredResult("(@.foo[:2])", "[[0, 1, 2], [3.0, 4.0, 5.0]]"), new Query_DesiredResult("(@.foo)[0]", "[0, 1, 2]"), + new Query_DesiredResult("(@.foo # comment\n)[0]", "[0, 1, 2]"), + new Query_DesiredResult("(@.foo)[0] # comment at end", "[0, 1, 2]"), + new Query_DesiredResult("(@.foo)[0] # comment at end\n", "[0, 1, 2]"), + new Query_DesiredResult("(@.foo)[0] #", "[0, 1, 2]"), // empty comment at end + new Query_DesiredResult("# comment at start\n(@.foo)[0]", "[0, 1, 2]"), + new Query_DesiredResult("# #s in comment #\r\n(@.foo)[0]", "[0, 1, 2]"), + new Query_DesiredResult("# comment at start\r\n# another comment\n(@.foo)[0]# moar comments!\n\n#yeah!!", "[0, 1, 2]"), // projection tests - new Query_DesiredResult("@{@.jub, @.quz}", "[[], {}]"), + new Query_DesiredResult("@ #\r\n{@.jub, @.quz}", "[[], {}]"), // comment is ignored new Query_DesiredResult("@.foo{foo: @[0], bar: @[1][:2]}", "{\"foo\": [0, 1, 2], \"bar\": [3.0, 4.0]}"), new Query_DesiredResult("sorted(flatten(@.guzo, 2)){`min`: @[0], `max`: @[-1], `tot`: sum(@)}", "{\"min\": 1, \"max\": 3, \"tot\": 6}"), new Query_DesiredResult("(@.foo[:]{`max`: max(@), `min`: min(@)})[0]", "{\"max\": 2.0, \"min\": 0.0}"), @@ -496,7 +503,7 @@ public static bool Test() // making sure various escapes work in backtickstrings new Query_DesiredResult("`\\t\\r\\n`", "\"\t\\r\\n\""), // "->" (map) operator - new Query_DesiredResult("@ -> len(@)", fooLen.ToString()), + new Query_DesiredResult("@ -> #cmnt\n len(@)", fooLen.ToString()), new Query_DesiredResult("@.foo[:] -> stringify(@)", "[\"[0,1,2]\", \"[3.0,4.0,5.0]\", \"[6.0,7.0,8.0]\"]"), new Query_DesiredResult("@.* -> 3", "{\"foo\": 3, \"bar\": 3, \"baz\": 3, \"quz\": 3, \"jub\": 3, \"guzo\": 3, \"7\": 3, \"_\": 3}"), new Query_DesiredResult("@.bar.* -> type(@)", "{\"a\": \"boolean\", \"b\": \"array\"}"), @@ -1004,6 +1011,8 @@ public static bool Test() new []{"var zuten = f`foo {@[0] = 3} bar`; @", "[1]"}, // mutation expression ('=' char) inside f-string interpolation new []{"hundenheim + f`{@[0]; @[1]}` ", "[0, 1]"}, // multiple statements (';' char) inside an f-string interpolation new []{"f`foo {} bar`", "[]"}, // empty interpolated section in f-string + new []{"# commment and nothing else", "[]" }, + new []{"# commment and nothing else\r\n# and another comment", "[]"}, }; // test issue where sometimes a binop does not raise an error when it operates on two invalid types string[] invalidOthers = new string[] { "{}", "[]", "\"1\"" }; @@ -1175,10 +1184,10 @@ public static bool Test() var testcases = new Query_DesiredResult[] { new Query_DesiredResult("var a = 1; " + - "var b = @.foo[0]; " + + "var b = @.foo # comment\r\n[0]; " + "var c = a + 2; " + "b = @ * c; " + // not reassigning b (use "var b = @ * c" for that), but rather mutating it - "@.foo[:][1]", + "@ #another comment\n.foo[:][ # more comments\n1]", "[3, 4.0, 7.0]"), new Query_DesiredResult("var two = @.foo[1]; " + // [3.0, 4.0, 5.0] "var one = @.foo[0]; " + // [0, 1, 2] @@ -1187,6 +1196,7 @@ public static bool Test() "two", "[8.0, 9.0, 10.0]"), new Query_DesiredResult("var two = @.foo[1]; " + // [3.0, 4.0, 5.0] + " # a comment;\r\n" + "var one = @.foo[0]; " + // [0, 1, 2] "var mintwo = min(two); " + // 3.0 "var z = one[:]{@, @ - mintwo};", // [[0, -3.0], [1, -2.0], [2, -1.0]] diff --git a/docs/RemesPath.md b/docs/RemesPath.md index e541d3c..15e0769 100644 --- a/docs/RemesPath.md +++ b/docs/RemesPath.md @@ -1399,4 +1399,17 @@ __Notes:__ Beginning in [v6.0](/CHANGELOG.md#600---2023-12-13), if a function has multiple optional arguments, you can leave any number of optional arguments (including the last) empty, rather than writing `null`. For example, if the function `foo` has two optional arguments: * `foo(1, , 2)` would be equivalent to `foo(1, null, 2)` -* `foo(1, 2, )` would be equivalent to `foo(1, 2, null)` or `foo(1, 2)`. \ No newline at end of file +* `foo(1, 2, )` would be equivalent to `foo(1, 2, null)` or `foo(1, 2)`. + +## Comments (added in [v6.2](/CHANGELOG.md#620---unreleased-yyyy-mm-dd)) ## + +Beginning in [v6.2](/CHANGELOG.md#620---unreleased-yyyy-mm-dd), queries can include any number of Python-style single-line comments. + +Thus the query +``` +foo # comment1 ++ #comment2 +# comment3 +bar #comment4 +``` +would simply be parsed as `foo + bar` \ No newline at end of file diff --git a/most recent errors.txt b/most recent errors.txt index 35a832b..6da24e5 100644 --- a/most recent errors.txt +++ b/most recent errors.txt @@ -1,4 +1,4 @@ -Test results for JsonTools v6.1.1.12 on Notepad++ 8.5.8 64bit +Test results for JsonTools v6.1.1.13 on Notepad++ 8.5.8 64bit NOTE: Ctrl-F (regular expressions *on*) for "Failed [1-9]\d*" to find all failed tests Tests failed: YAML dumper ========================= @@ -107,13 +107,13 @@ Testing RemesPath parser and compiler The queried JSON in the RemesParser tests is named foo:{"foo": [[0, 1, 2], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]], "bar": {"a": false, "b": ["a`g", "bah"]}, "baz": "z", "quz": {}, "jub": [], "guzo": [[[1]], [[2], [3]]], "7": [{"foo": 2}, 1], "_": {"0": 0}} Failed 0 tests. -Passed 495 tests. +Passed 502 tests. ========================= Testing RemesPath throws errors on bad inputs ========================= Failed 0 tests. -Passed 649 tests. +Passed 651 tests. ========================= Testing RemesPath assignment operations ========================= @@ -195,33 +195,33 @@ Testing JsonParser performance Preview of json: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... -To convert JSON string of size 89556 into JNode took 2.965 +/- 2.148 ms over 32 trials -Load times (ms): 13, 3, 3, 2, 2, 5, 1, 1, 1, 3, 1, 1, 4, 1, 1, 1, 2, 1, 1, 4, 1, 2, 2, 3, 1, 1, 4, 2, 2, 2, 3, 1 +To convert JSON string of size 89556 into JNode took 3.291 +/- 2.914 ms over 32 trials +Load times (ms): 3, 1, 2, 5, 17, 1, 1, 3, 1, 1, 3, 1, 1, 1, 3, 2, 2, 6, 2, 2, 2, 4, 2, 2, 6, 1, 1, 1, 2, 5, 2, 2 ========================= Performance tests for RemesPath (float arithmetic) ========================= -Compiling query "@[@[:].a * @[:].t < @[:].e]" took 0.055 ms the first time, including approximately 0.054 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[@[:].a * @[:].t < @[:].e]" on JNode from JSON of size 89556 into took 0.116 +/- 0.559 ms over 40 trials -Query times (ms): 0.058, 0.036, 0.024, 0.023, 0.027, 0.023, 0.024, 0.033, 0.023, 0.023, 0.025, 0.024, 0.024, 0.03, 0.024, 0.023, 0.023, 0.023, 0.025, 0.047, 0.024, 0.025, 0.024, 0.024, 0.026, 0.035, 0.024, 3.605, 0.024, 0.022, 0.022, 0.03, 0.024, 0.023, 0.024, 0.023, 0.023, 0.026, 0.024, 0.023 +Compiling query "@[@[:].a * @[:].t < @[:].e]" took 0.145 ms the first time, including approximately 0.151 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[@[:].a * @[:].t < @[:].e]" on JNode from JSON of size 89556 into took 0.126 +/- 0.525 ms over 40 trials +Query times (ms): 0.127, 0.084, 0.037, 0.032, 0.033, 0.037, 0.036, 0.075, 0.059, 0.043, 0.038, 0.041, 0.048, 0.043, 0.045, 0.036, 0.039, 0.032, 0.03, 0.044, 0.037, 0.035, 0.04, 0.038, 0.051, 0.038, 0.033, 0.037, 0.034, 0.039, 0.034, 0.04, 0.035, 0.033, 0.032, 0.037, 0.031, 0.037, 0.033, 3.404 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= Performance tests for RemesPath (string operations) ========================= -Compiling query "@[@[:].z =~ `(?i)[a-z]{5}`]" took 0.049 ms the first time, including approximately 0.059 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[@[:].z =~ `(?i)[a-z]{5}`]" on JNode from JSON of size 89556 into took 0.083 +/- 0.007 ms over 40 trials -Query times (ms): 0.122, 0.087, 0.08, 0.082, 0.08, 0.081, 0.082, 0.089, 0.08, 0.083, 0.082, 0.082, 0.081, 0.082, 0.08, 0.079, 0.08, 0.078, 0.08, 0.082, 0.079, 0.079, 0.078, 0.081, 0.088, 0.082, 0.083, 0.082, 0.083, 0.081, 0.082, 0.08, 0.083, 0.082, 0.083, 0.081, 0.082, 0.08, 0.082, 0.082 +Compiling query "@[@[:].z =~ `(?i)[a-z]{5}`]" took 0.061 ms the first time, including approximately 0.051 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[@[:].z =~ `(?i)[a-z]{5}`]" on JNode from JSON of size 89556 into took 0.087 +/- 0.02 ms over 40 trials +Query times (ms): 0.145, 0.189, 0.084, 0.082, 0.081, 0.081, 0.081, 0.083, 0.08, 0.082, 0.081, 0.081, 0.081, 0.079, 0.082, 0.104, 0.081, 0.085, 0.087, 0.082, 0.08, 0.082, 0.08, 0.081, 0.079, 0.082, 0.081, 0.082, 0.079, 0.088, 0.08, 0.083, 0.086, 0.08, 0.083, 0.082, 0.081, 0.083, 0.084, 0.082 Preview of result: [{"A": "\n]o1VQ5t6g", "a": 4710024278, "b": 3268860721, "B": "g4Y7+ew^.v", "C": "NK nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" took 0.141 ms the first time, including approximately 0.309 ms to tokenize the query. Subsequent executions are effectively free due to caching. +ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" took 0.142 ms the first time, including approximately 0.152 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var qmask = @[:].q; var nmax_q = max(@[qmask].n); var nmax_notq = max(@[not qmask].n); -ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" on JNode from JSON of size 89556 into took 0.018 +/- 0.01 ms over 40 trials -Query times (ms): 0.08, 0.018, 0.017, 0.018, 0.017, 0.016, 0.016, 0.017, 0.018, 0.016, 0.017, 0.017, 0.017, 0.017, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.017, 0.016, 0.016, 0.017, 0.017, 0.017, 0.016, 0.018, 0.017, 0.016, 0.016, 0.017, 0.016, 0.016, 0.016, 0.017, 0.016, 0.016, 0.017, 0.018 +ifelse(nmax_q > nmax_notq, `when q=true, nmax = ` + str(nmax_q), `when q=false, nmax= ` + str(nmax_notq))" on JNode from JSON of size 89556 into took 0.032 +/- 0.045 ms over 40 trials +Query times (ms): 0.313, 0.036, 0.024, 0.024, 0.025, 0.025, 0.024, 0.031, 0.024, 0.025, 0.024, 0.024, 0.024, 0.026, 0.024, 0.023, 0.024, 0.024, 0.024, 0.024, 0.027, 0.023, 0.022, 0.024, 0.024, 0.024, 0.024, 0.024, 0.024, 0.025, 0.023, 0.024, 0.025, 0.026, 0.024, 0.024, 0.026, 0.024, 0.023, 0.023 Preview of result: "when q=false, nmax= 9830935647.0" ... ========================= @@ -260,11 +260,11 @@ Performance tests for RemesPath (references to compile-time constant variables) Compiling query "var X = X; var onetwo = j`[1, 2]`; -@[:]->at(@, X)->at(@, onetwo)" took 0.075 ms the first time, including approximately 0.17 ms to tokenize the query. Subsequent executions are effectively free due to caching. +@[:]->at(@, X)->at(@, onetwo)" took 0.182 ms the first time, including approximately 0.125 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var X = X; var onetwo = j`[1, 2]`; -@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.015 +/- 0.006 ms over 40 trials -Query times (ms): 0.045, 0.035, 0.014, 0.013, 0.012, 0.013, 0.016, 0.014, 0.014, 0.013, 0.014, 0.013, 0.013, 0.013, 0.013, 0.013, 0.013, 0.014, 0.015, 0.014, 0.013, 0.014, 0.013, 0.014, 0.014, 0.014, 0.014, 0.015, 0.014, 0.014, 0.012, 0.014, 0.014, 0.014, 0.013, 0.013, 0.013, 0.013, 0.012, 0.013 +@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.033 +/- 0.02 ms over 40 trials +Query times (ms): 0.07, 0.026, 0.022, 0.024, 0.021, 0.134, 0.03, 0.024, 0.034, 0.025, 0.036, 0.024, 0.022, 0.024, 0.027, 0.027, 0.026, 0.026, 0.039, 0.028, 0.054, 0.061, 0.029, 0.026, 0.038, 0.035, 0.02, 0.023, 0.024, 0.024, 0.025, 0.02, 0.024, 0.04, 0.021, 0.057, 0.028, 0.025, 0.024, 0.024 Preview of result: [[1695727848, 0.287562638736685], [2126430375, 0.00767794129708177], [5310550656, 0.380769772645687], [2519183283, 0.153176220930558], [6610062385, 0.662996225870666], [987168256, 0.924410189999928], [6615003609, 0.917112691225947], [4465232046, 0.684311931851536], [8654414565, 0.631485392105992], [ ... ========================= @@ -273,29 +273,29 @@ Performance tests for RemesPath (references to variables that are not compile-ti Compiling query "var X = @->`X`; var onetwo = @{1, 2}; -@[:]->at(@, X)->at(@, onetwo)" took 0.087 ms the first time, including approximately 0.072 ms to tokenize the query. Subsequent executions are effectively free due to caching. +@[:]->at(@, X)->at(@, onetwo)" took 0.124 ms the first time, including approximately 0.118 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var X = @->`X`; var onetwo = @{1, 2}; -@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.026 +/- 0.054 ms over 40 trials -Query times (ms): 0.05, 0.017, 0.017, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.018, 0.016, 0.017, 0.016, 0.016, 0.016, 0.017, 0.016, 0.016, 0.032, 0.018, 0.363, 0.026, 0.016, 0.016, 0.015, 0.015, 0.015, 0.016, 0.015, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016 +@[:]->at(@, X)->at(@, onetwo)" on JNode from JSON of size 89556 into took 0.025 +/- 0.047 ms over 40 trials +Query times (ms): 0.063, 0.017, 0.016, 0.017, 0.016, 0.312, 0.028, 0.016, 0.016, 0.015, 0.016, 0.016, 0.016, 0.016, 0.016, 0.015, 0.016, 0.016, 0.016, 0.016, 0.016, 0.015, 0.016, 0.016, 0.016, 0.016, 0.016, 0.015, 0.016, 0.016, 0.016, 0.016, 0.017, 0.016, 0.016, 0.016, 0.016, 0.016, 0.017, 0.016 Preview of result: [[1695727848, 0.287562638736685], [2126430375, 0.00767794129708177], [5310550656, 0.380769772645687], [2519183283, 0.153176220930558], [6610062385, 0.662996225870666], [987168256, 0.924410189999928], [6615003609, 0.917112691225947], [4465232046, 0.684311931851536], [8654414565, 0.631485392105992], [ ... ========================= Performance tests for RemesPath (simple string mutations) ========================= -Compiling query "@[:].z = s_sub(@, g, B)" took 0.065 ms the first time, including approximately 0.059 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[:].z = s_sub(@, g, B)" on JNode from JSON of size 89556 into took 0.025 +/- 0.009 ms over 40 trials -Query times (ms): 0.032, 0.02, 0.017, 0.028, 0.021, 0.027, 0.024, 0.017, 0.018, 0.018, 0.018, 0.038, 0.042, 0.038, 0.035, 0.043, 0.03, 0.04, 0.026, 0.043, 0.035, 0.024, 0.014, 0.014, 0.015, 0.017, 0.015, 0.013, 0.013, 0.013, 0.013, 0.032, 0.029, 0.029, 0.025, 0.022, 0.023, 0.025, 0.024, 0.026 +Compiling query "@[:].z = s_sub(@, g, B)" took 0.061 ms the first time, including approximately 0.058 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[:].z = s_sub(@, g, B)" on JNode from JSON of size 89556 into took 0.085 +/- 0.347 ms over 40 trials +Query times (ms): 0.036, 0.024, 0.014, 0.041, 0.022, 0.052, 0.08, 0.03, 0.022, 0.033, 0.037, 0.046, 0.033, 0.039, 0.033, 0.029, 2.253, 0.024, 0.022, 0.025, 0.022, 0.022, 0.032, 0.022, 0.022, 0.025, 0.022, 0.021, 0.021, 0.02, 0.042, 0.054, 0.026, 0.021, 0.022, 0.022, 0.022, 0.022, 0.014, 0.014 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= Performance tests for RemesPath (simple number mutations) ========================= -Compiling query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" took 0.093 ms the first time, including approximately 0.099 ms to tokenize the query. Subsequent executions are effectively free due to caching. -To run pre-compiled query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" on JNode from JSON of size 89556 into took 0.047 +/- 0.015 ms over 40 trials -Query times (ms): 0.058, 0.064, 0.055, 0.04, 0.021, 0.02, 0.046, 0.043, 0.041, 0.038, 0.035, 0.044, 0.043, 0.064, 0.05, 0.054, 0.061, 0.096, 0.048, 0.054, 0.047, 0.04, 0.064, 0.043, 0.048, 0.051, 0.044, 0.06, 0.058, 0.062, 0.035, 0.042, 0.038, 0.08, 0.037, 0.033, 0.032, 0.035, 0.036, 0.034 +Compiling query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" took 0.096 ms the first time, including approximately 0.115 ms to tokenize the query. Subsequent executions are effectively free due to caching. +To run pre-compiled query "@[:].x = ifelse(@ < 0.5, @ + 3, @ - 3)" on JNode from JSON of size 89556 into took 0.026 +/- 0.008 ms over 40 trials +Query times (ms): 0.052, 0.043, 0.036, 0.022, 0.038, 0.033, 0.035, 0.037, 0.02, 0.02, 0.021, 0.018, 0.028, 0.027, 0.026, 0.026, 0.033, 0.02, 0.019, 0.021, 0.02, 0.019, 0.022, 0.019, 0.018, 0.032, 0.02, 0.019, 0.03, 0.047, 0.025, 0.031, 0.021, 0.02, 0.022, 0.02, 0.02, 0.022, 0.022, 0.022 Preview of result: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... ========================= @@ -305,12 +305,12 @@ Performance tests for RemesPath (mutations with a for loop) Compiling query "var xhalf = @[:].x < 0.5; for lx = zip(@[:].l, xhalf); lx[0] = ifelse(lx[1], foo, bar); -end for;" took 0.174 ms the first time, including approximately 0.158 ms to tokenize the query. Subsequent executions are effectively free due to caching. +end for;" took 0.152 ms the first time, including approximately 0.149 ms to tokenize the query. Subsequent executions are effectively free due to caching. To run pre-compiled query "var xhalf = @[:].x < 0.5; for lx = zip(@[:].l, xhalf); lx[0] = ifelse(lx[1], foo, bar); -end for;" on JNode from JSON of size 89556 into took 0.069 +/- 0.023 ms over 40 trials -Query times (ms): 0.108, 0.103, 0.079, 0.074, 0.073, 0.074, 0.068, 0.078, 0.114, 0.082, 0.079, 0.076, 0.044, 0.068, 0.067, 0.072, 0.064, 0.065, 0.065, 0.08, 0.069, 0.048, 0.044, 0.045, 0.043, 0.043, 0.043, 0.042, 0.043, 0.044, 0.042, 0.065, 0.089, 0.116, 0.12, 0.117, 0.069, 0.054, 0.04, 0.039 +end for;" on JNode from JSON of size 89556 into took 0.059 +/- 0.018 ms over 40 trials +Query times (ms): 0.085, 0.046, 0.044, 0.042, 0.042, 0.042, 0.042, 0.047, 0.042, 0.042, 0.041, 0.042, 0.042, 0.058, 0.045, 0.042, 0.041, 0.043, 0.041, 0.044, 0.087, 0.119, 0.065, 0.065, 0.065, 0.068, 0.082, 0.067, 0.065, 0.067, 0.066, 0.062, 0.066, 0.069, 0.065, 0.06, 0.06, 0.068, 0.1, 0.066 Preview of result: [["bar", false], ["bar", false], ["foo", true], ["foo", true], ["foo", true], ["foo", true], ["foo", true], ["bar", false], ["bar", false], ["bar", false], ["foo", true], ["foo", true], ["bar", false], ["bar", false], ["foo", true], ["bar", false], ["bar", false], ["bar", false], ["foo", true], ["ba ... ========================= @@ -319,18 +319,18 @@ Testing performance of JSON compression and pretty-printing Preview of json: [{"A": "Ky'c^g#~)0", "a": 1850111954, "b": 9318359041, "B": "Oyi:/ xxe2", "C": "sKCSa_^7Gg", "c": 7974777124, "d": 2670309238, "D": "0d_K)HmX!.", "E": ".uM*Z{0EJ_", "e": 6958410336, "f": 8050244728, "F": "1%SG_A!xB\t", "g": 3799657125, "G": "il1^k\\\nat*", "H": {"a": 6079042826, "b": 7292804611, "c" ... -To compress JNode from JSON string of 89556 took 4.203 +/- 0.669 ms over 64 trials (minimal whitespace, sortKeys=TRUE) -To compress JNode from JSON string of 89556 took 2.052 +/- 0.232 ms over 64 trials (minimal whitespace, sortKeys=FALSE) -To Google-style pretty-print JNode from JSON string of 89556 took 4.422 +/- 0.976 ms over 64 trials (sortKeys=true, indent=4) -To Whitesmith-style pretty-print JNode from JSON string of 89556 took 4.078 +/- 0.256 ms over 64 trials (sortKeys=true, indent=4) -To PPrint-style pretty-print JNode from JSON string of 89556 took 6.579 +/- 0.985 ms over 64 trials (sortKeys=true, indent=4) +To compress JNode from JSON string of 89556 took 5.298 +/- 0.78 ms over 64 trials (minimal whitespace, sortKeys=TRUE) +To compress JNode from JSON string of 89556 took 2.875 +/- 0.867 ms over 64 trials (minimal whitespace, sortKeys=FALSE) +To Google-style pretty-print JNode from JSON string of 89556 took 4.868 +/- 0.702 ms over 64 trials (sortKeys=true, indent=4) +To Whitesmith-style pretty-print JNode from JSON string of 89556 took 4.999 +/- 0.971 ms over 64 trials (sortKeys=true, indent=4) +To PPrint-style pretty-print JNode from JSON string of 89556 took 5.991 +/- 0.984 ms over 64 trials (sortKeys=true, indent=4) ========================= Testing performance of JsonSchemaValidator and random JSON creation ========================= -To create a random set of tweet JSON of size 162585 (15 tweets) based on the matching schema took 6.216 +/- 2.957 ms over 64 trials -To compile the tweet schema to a validation function took 0.207 +/- 0.032 ms over 64 trials -To validate tweet JSON of size 162585 (15 tweets) based on the compiled schema took 0.994 +/- 0.167 ms over 64 trials +To create a random set of tweet JSON of size 183926 (15 tweets) based on the matching schema took 6.517 +/- 3.037 ms over 64 trials +To compile the tweet schema to a validation function took 0.211 +/- 0.04 ms over 64 trials +To validate tweet JSON of size 183926 (15 tweets) based on the compiled schema took 1.04 +/- 0.192 ms over 64 trials ========================= Testing JSON grepper's API request tool =========================