Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: LayoutTests/inspector/json-balanced-tokenizer.html

Issue 967853002: DevTools: n^2 -> n while loading heap snapshots and timeline files. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed the load test. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/inspector/json-balanced-tokenizer.html
diff --git a/LayoutTests/inspector/json-balanced-tokenizer.html b/LayoutTests/inspector/json-balanced-tokenizer.html
new file mode 100644
index 0000000000000000000000000000000000000000..90a290e393a796276c57faab974895887d6feef5
--- /dev/null
+++ b/LayoutTests/inspector/json-balanced-tokenizer.html
@@ -0,0 +1,102 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test.js"></script>
+
+<script>
+function test()
+{
+ InspectorTest.runTestSuite([
+ function testMatchQuotes(next)
+ {
+ var testStrings = [
+ {"odd back slashes with text around":"tes\\\"t"},
+ {"escaped double quotes":"\"test\""},
+ {"escaped back slash before double quote":"test\\"},
+ {1:2},
+ {"":""},
+ {"nested brackets":{}},
+ {"nested brackets with double quotes":{"":""}},
+ {"etc":{"\\":"\""}},
+ {"etc":{"\\\\":"\\"}},
+ {"etc":{"\\\\\"":"\\\\\""}}
+ ];
+
+ for (var i = 0; i < testStrings.length; ++i) {
+ var string = JSON.stringify(testStrings[i]);
+ InspectorTest.addResult("\nParsing " + string);
+ var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest));
+ tokenizer.write(string);
+ }
+ next();
+ },
+
+ function testMatchSequenceUsingOneShot(next)
+ {
+ var testData = [
+ {"one":"one"},
+ [{"one":"one"}, {"two":"two"}],
+ [{"one":"one"}, {"two":"two"}, {"three":"three"}],
+ ];
+
+ for (var i = 0; i < testData.length; ++i) {
+ var string = JSON.stringify(testData[i]);
+ InspectorTest.addResult("\nParsing " + string);
+ var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest));
+ tokenizer.write(string);
+ }
+ next();
+ },
+
+ function testMatchSequenceUsingMultiple(next)
+ {
+ var testData = [
+ {"one":"one"},
+ [{"one":"one"}, {"two":"two"}],
+ [{"one":"one"}, {"two":"two"}, {"three":"three"}],
+ ];
+
+ for (var i = 0; i < testData.length; ++i) {
+ var string = JSON.stringify(testData[i]);
+ InspectorTest.addResult("\nParsing " + string);
+ var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
+ tokenizer.write(string);
+ }
+ next();
+ },
+
+ function testIncrementalWrites(next)
+ {
+ var testStrings = [
+ {"odd back slashes with text around":"tes\\\"t"},
+ {"escaped double quotes":"\"test\""},
+ {"escaped back slash before double quote":"test\\"},
+ {1:2},
+ {"":""},
+ {"nested brackets":{}},
+ {"nested brackets with double quotes":{"":""}},
+ {"etc":{"\\":"\""}},
+ {"etc":{"\\\\":"\\"}},
+ {"etc":{"\\\\\"":"\\\\\""}}
+ ];
+ var string = JSON.stringify(testStrings);
+ var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
+ InspectorTest.addResult("\nRunning at once:");
+ tokenizer.write(string);
+
+ for (var sample of [3, 15, 50]) {
+ tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(InspectorTest.addResult.bind(InspectorTest), true);
+ InspectorTest.addResult("\nRunning by " + sample + ":");
+ for (var i = 0; i < string.length; i += sample)
+ tokenizer.write(string.substring(i, i + sample));
+ }
+ next();
+ }
+ ]);
+}
+</script>
+
+<body onload="runTest()">
+Test WebInspector.TextUtils.BalancedJSONTokenizer.
+</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698