@@ -42,38 +42,66 @@ for (let fileSize of fileSizes) {
4242 iterations : 10
4343 } ) ;
4444
45- for ( let i of [ 10 , 100 , 1000 ] ) {
46- editsSuite . add ( {
47- name : `apply ${ i } edits` ,
48- buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
49- chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
50- return textBufferBuilder . finish ( ) ;
51- } ,
52- preCycle : ( textBuffer ) => {
53- return textBuffer ;
54- } ,
55- fn : ( textBuffer ) => {
56- // for line model, this loop doesn't reflect the real situation.
57- for ( let k = 0 ; k < edits . length && k < i ; k ++ ) {
58- textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
59- }
45+ editsSuite . add ( {
46+ name : `apply 1000 edits` ,
47+ buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
48+ chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
49+ return textBufferBuilder . finish ( ) ;
50+ } ,
51+ preCycle : ( textBuffer ) => {
52+ return textBuffer ;
53+ } ,
54+ fn : ( textBuffer ) => {
55+ // for line model, this loop doesn't reflect the real situation.
56+ for ( let k = 0 ; k < edits . length ; k ++ ) {
57+ textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
6058 }
61- } ) ;
59+ }
60+ } ) ;
6261
63- editsSuite . add ( {
64- name : `Read all lines after ${ i } edits` ,
65- buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
66- chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
67- return textBufferBuilder . finish ( ) ;
68- } ,
69- preCycle : ( textBuffer ) => {
70- for ( let k = 0 ; k < edits . length && k < i ; k ++ ) {
71- textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
72- }
73- return textBuffer ;
74- } ,
75- fn : ( textBuffer ) => {
76- for ( let j = 0 , len = textBuffer . getLineCount ( ) ; j < len ; j ++ ) {
62+ editsSuite . add ( {
63+ name : `Read all lines after 1000 edits` ,
64+ buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
65+ chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
66+ return textBufferBuilder . finish ( ) ;
67+ } ,
68+ preCycle : ( textBuffer ) => {
69+ for ( let k = 0 ; k < edits . length ; k ++ ) {
70+ textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
71+ }
72+ return textBuffer ;
73+ } ,
74+ fn : ( textBuffer ) => {
75+ for ( let j = 0 , len = textBuffer . getLineCount ( ) ; j < len ; j ++ ) {
76+ var str = textBuffer . getLineContent ( j + 1 ) ;
77+ let firstChar = str . charCodeAt ( 0 ) ;
78+ let lastChar = str . charCodeAt ( str . length - 1 ) ;
79+ firstChar = firstChar - lastChar ;
80+ lastChar = firstChar + lastChar ;
81+ firstChar = lastChar - firstChar ;
82+ }
83+ }
84+ } ) ;
85+
86+ editsSuite . add ( {
87+ name : `Read 10 random windows after 1000 edits` ,
88+ buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
89+ chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
90+ return textBufferBuilder . finish ( ) ;
91+ } ,
92+ preCycle : ( textBuffer ) => {
93+ for ( let k = 0 ; k < edits . length ; k ++ ) {
94+ textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
95+ }
96+ return textBuffer ;
97+ } ,
98+ fn : ( textBuffer ) => {
99+ for ( let i = 0 ; i < 10 ; i ++ ) {
100+ let minLine = 1 ;
101+ let maxLine = textBuffer . getLineCount ( ) ;
102+ let startLine = getRandomInt ( minLine , Math . max ( minLine , maxLine - 100 ) ) ;
103+ let endLine = Math . min ( maxLine , startLine + 100 ) ;
104+ for ( let j = startLine ; j < endLine ; j ++ ) {
77105 var str = textBuffer . getLineContent ( j + 1 ) ;
78106 let firstChar = str . charCodeAt ( 0 ) ;
79107 let lastChar = str . charCodeAt ( str . length - 1 ) ;
@@ -82,57 +110,27 @@ for (let fileSize of fileSizes) {
82110 firstChar = lastChar - firstChar ;
83111 }
84112 }
85- } ) ;
86-
87- editsSuite . add ( {
88- name : `Read 10 random windows after ${ i } edits` ,
89- buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
90- chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
91- return textBufferBuilder . finish ( ) ;
92- } ,
93- preCycle : ( textBuffer ) => {
94- for ( let k = 0 ; k < edits . length && k < i ; k ++ ) {
95- textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
96- }
97- return textBuffer ;
98- } ,
99- fn : ( textBuffer ) => {
100- for ( let i = 0 ; i < 10 ; i ++ ) {
101- let minLine = 1 ;
102- let maxLine = textBuffer . getLineCount ( ) ;
103- let startLine = getRandomInt ( minLine , Math . max ( minLine , maxLine - 100 ) ) ;
104- let endLine = Math . min ( maxLine , startLine + 100 ) ;
105- for ( let j = startLine ; j < endLine ; j ++ ) {
106- var str = textBuffer . getLineContent ( j + 1 ) ;
107- let firstChar = str . charCodeAt ( 0 ) ;
108- let lastChar = str . charCodeAt ( str . length - 1 ) ;
109- firstChar = firstChar - lastChar ;
110- lastChar = firstChar + lastChar ;
111- firstChar = lastChar - firstChar ;
112- }
113- }
114- }
115- } ) ;
113+ }
114+ } ) ;
116115
117- editsSuite . add ( {
118- name : `save file after ${ i } edits` ,
119- buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
120- chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
121- return textBufferBuilder . finish ( ) ;
122- } ,
123- preCycle : ( textBuffer ) => {
124- for ( let k = 0 ; k < edits . length && k < i ; k ++ ) {
125- textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
126- }
127- return textBuffer ;
128- } ,
129- fn : ( textBuffer ) => {
130- const lineCount = textBuffer . getLineCount ( ) ;
131- const fullModelRange = new Range ( 1 , 1 , lineCount , textBuffer . getLineLength ( lineCount ) + 1 ) ;
132- textBuffer . getValueInRange ( fullModelRange , EndOfLinePreference . LF ) ;
116+ editsSuite . add ( {
117+ name : `save file after 1000 edits` ,
118+ buildBuffer : ( textBufferBuilder : ITextBufferBuilder ) => {
119+ chunks . forEach ( ck => textBufferBuilder . acceptChunk ( ck ) ) ;
120+ return textBufferBuilder . finish ( ) ;
121+ } ,
122+ preCycle : ( textBuffer ) => {
123+ for ( let k = 0 ; k < edits . length ; k ++ ) {
124+ textBuffer . applyEdits ( [ edits [ k ] ] , false ) ;
133125 }
134- } ) ;
135- }
126+ return textBuffer ;
127+ } ,
128+ fn : ( textBuffer ) => {
129+ const lineCount = textBuffer . getLineCount ( ) ;
130+ const fullModelRange = new Range ( 1 , 1 , lineCount , textBuffer . getLineLength ( lineCount ) + 1 ) ;
131+ textBuffer . getValueInRange ( fullModelRange , EndOfLinePreference . LF ) ;
132+ }
133+ } ) ;
136134
137135 editsSuite . run ( ) ;
138136 }
0 commit comments