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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4
5 <script>
6 function test()
7 {
8 InspectorTest.runTestSuite([
9 function testMatchQuotes(next)
10 {
11 var testStrings = [
12 {"odd back slashes with text around":"tes\\\"t"},
13 {"escaped double quotes":"\"test\""},
14 {"escaped back slash before double quote":"test\\"},
15 {1:2},
16 {"":""},
17 {"nested brackets":{}},
18 {"nested brackets with double quotes":{"":""}},
19 {"etc":{"\\":"\""}},
20 {"etc":{"\\\\":"\\"}},
21 {"etc":{"\\\\\"":"\\\\\""}}
22 ];
23
24 for (var i = 0; i < testStrings.length; ++i) {
25 var string = JSON.stringify(testStrings[i]);
26 InspectorTest.addResult("\nParsing " + string);
27 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest));
28 tokenizer.write(string);
29 }
30 next();
31 },
32
33 function testMatchSequenceUsingOneShot(next)
34 {
35 var testData = [
36 {"one":"one"},
37 [{"one":"one"}, {"two":"two"}],
38 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
39 ];
40
41 for (var i = 0; i < testData.length; ++i) {
42 var string = JSON.stringify(testData[i]);
43 InspectorTest.addResult("\nParsing " + string);
44 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest));
45 tokenizer.write(string);
46 }
47 next();
48 },
49
50 function testMatchSequenceUsingMultiple(next)
51 {
52 var testData = [
53 {"one":"one"},
54 [{"one":"one"}, {"two":"two"}],
55 [{"one":"one"}, {"two":"two"}, {"three":"three"}],
56 ];
57
58 for (var i = 0; i < testData.length; ++i) {
59 var string = JSON.stringify(testData[i]);
60 InspectorTest.addResult("\nParsing " + string);
61 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer (InspectorTest.addResult.bind(InspectorTest), true);
62 tokenizer.write(string);
63 }
64 next();
65 },
66
67 function testIncrementalWrites(next)
68 {
69 var testStrings = [
70 {"odd back slashes with text around":"tes\\\"t"},
71 {"escaped double quotes":"\"test\""},
72 {"escaped back slash before double quote":"test\\"},
73 {1:2},
74 {"":""},
75 {"nested brackets":{}},
76 {"nested brackets with double quotes":{"":""}},
77 {"etc":{"\\":"\""}},
78 {"etc":{"\\\\":"\\"}},
79 {"etc":{"\\\\\"":"\\\\\""}}
80 ];
81 var string = JSON.stringify(testStrings);
82 var tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Ins pectorTest.addResult.bind(InspectorTest), true);
83 InspectorTest.addResult("\nRunning at once:");
84 tokenizer.write(string);
85
86 for (var sample of [3, 15, 50]) {
87 tokenizer = new WebInspector.TextUtils.BalancedJSONTokenizer(Ins pectorTest.addResult.bind(InspectorTest), true);
88 InspectorTest.addResult("\nRunning by " + sample + ":");
89 for (var i = 0; i < string.length; i += sample)
90 tokenizer.write(string.substring(i, i + sample));
91 }
92 next();
93 }
94 ]);
95 }
96 </script>
97
98 <body onload="runTest()">
99 Test WebInspector.TextUtils.BalancedJSONTokenizer.
100 </p>
101 </body>
102 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698