-
Notifications
You must be signed in to change notification settings - Fork 12
/
results.txt
305 lines (268 loc) · 6.52 KB
/
results.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
################
# gabe_bell.rb #
################
## Interesting
# Uses character based diffing
# Quacks a bit like a String
## Problems
# Patches String to add diff() function
# Introduces a subtle bug into remove_text()
# Introduces severe performance issues
$ ruby memory_test.rb
Starting Memory:
1492
Adding 100 characters, 1 at a time
Current memory footprint:
1652
Adding 1000 characters, 1 at a time
Current memory footprint:
2488
Adding 10000 characters, 1 at a time
Current memory footprint:
6776
Took 109.109232s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
......F..F
Finished in 0.007925 seconds.
1) Failure:
test_can_delete_between_a_start_and_end_point(DocumentTest::TestDocumentRemove_text) [test/document_test.rb:55]:
<"Held"> expected but was
<"He">.
2) Failure:
test_can_undo_remove_text_operations(DocumentTest::TestDocumentUndo) [test/document_test.rb:94]:
<"Hlo"> expected but was
<"Ho">.
10 tests, 13 assertions, 2 failures, 0 errors
## Interesting
# Change tracking
## Problems
# make_change a monolith
################
# tim_liner.rb #
################
$ ruby memory_test.rb
Starting Memory:
1488
Adding 100 characters, 1 at a time
Current memory footprint:
1516
Adding 1000 characters, 1 at a time
Current memory footprint:
1608
Adding 10000 characters, 1 at a time
Current memory footprint:
2788
Adding 100000 characters, 1 at a time
Current memory footprint:
11672
Took 3.371039s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.001467 seconds.
10 tests, 14 assertions, 0 failures, 0 errors
###################
# walton_hoops.rb #
###################
## Interesting
# Uses 'versioning' metaphor
#
# Problems:
# A bit verbose and low level
$ ruby memory_test.rb
Starting Memory:
1492
Adding 100 characters, 1 at a time
Current memory footprint:
1528
Adding 1000 characters, 1 at a time
Current memory footprint:
1700
Adding 10000 characters, 1 at a time
Current memory footprint:
3044
Adding 100000 characters, 1 at a time
Current memory footprint:
13452
Took 4.613792s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.001601 seconds.
10 tests, 14 assertions, 0 failures, 0 errors
#####################
# ricardo_mendes.rb #
#####################
#
## Interesting
# Uses an explicit operations stack
# content is generated from op stack on demand
#
# Problems
# contents redefines attr_reader (should remove attr_reader)
# contents destructively updates an instance variable
# contents is recalculated each time, without caching (possible performance issue)
$ ruby memory_test.rb
Starting Memory:
1488
Adding 100 characters, 1 at a time
Current memory footprint:
1516
Adding 1000 characters, 1 at a time
Current memory footprint:
1640
Adding 10000 characters, 1 at a time
Current memory footprint:
3124
Adding 100000 characters, 1 at a time
Current memory footprint:
21840
Took 6.394071s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.000984 seconds.
10 tests, 14 assertions, 0 failures, 0 errors
##############################
# alberto_fernandez_capel.rb #
##############################
#
## Interesting:
# Standard "Design Pattern" implementation
# execute() centralizes the reverted stack reset
# My initial solution was similar
#
# Problems
# Slightly more memory intensive
# Super verbose
$ ruby memory_test.rb
Starting Memory:
1492
Adding 100 characters, 1 at a time
Current memory footprint:
1528
Adding 1000 characters, 1 at a time
Current memory footprint:
1700
Adding 10000 characters, 1 at a time
Current memory footprint:
3012
Adding 100000 characters, 1 at a time
Current memory footprint:
16812
Took 4.686938s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.000984 seconds.
10 tests, 14 assertions, 0 failures, 0 errors
################
# ali_rizvi.rb #
################
#
## Interesting:
# Most terse solution submitted
# Leverages lambdas for lazy evaluation
# Content generated on demand
#
## Problems
# Content not cached, possible performance issue
# Subtle bug because reverted stack not cleared (see irb session below)
>> require "ali_rizvi"
=> true
>> t = TextEditor::Document.new
=> #<TextEditor::Document:0x6a964 @reverted=[], @commands=[], @contents="">
>> t.add_text "Hello World"
=> [#<Proc:0x00072754@./lib/ali_rizvi.rb:16>]
>> t.contents
=> "Hello World"
>> t.add_text " Cup"
=> [#<Proc:0x00072754@./lib/ali_rizvi.rb:16>, #<Proc:0x00072754@./lib/ali_rizvi.rb:16>]
>> t.contents
=> "Hello World Cup"
>> t.undo
=> [#<Proc:0x00072754@./lib/ali_rizvi.rb:16>]
>> t.contents
=> "Hello World"
>> t.add_text(" Butter")
=> [#<Proc:0x00072754@./lib/ali_rizvi.rb:16>, #<Proc:0x00072754@./lib/ali_rizvi.rb:16>]
>> t.redo
=> [#<Proc:0x00072754@./lib/ali_rizvi.rb:16>, #<Proc:0x00072754@./lib/ali_rizvi.rb:16>, #<Proc:0x00072754@./lib/ali_rizvi.rb:16>]
>> t.contents
=> "Hello World Butter Cup"
$ ruby memory_test.rb
Starting Memory:
1484
Adding 100 characters, 1 at a time
Current memory footprint:
1540
Adding 1000 characters, 1 at a time
Current memory footprint:
1940
Adding 10000 characters, 1 at a time
Current memory footprint:
6792
Adding 100000 characters, 1 at a time
Current memory footprint:
52160
Took 0.349649s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.001265 seconds.
10 tests, 14 assertions, 0 failures, 0 errors
######################
# ali_rizvi_fixed.rb #
######################
#
## Interesting
# Minor tweaks to Ali Rizvi's solution by Gregory Brown
# to incorporate Alberto's execute() idea and fix the redo issue.
#
## Problems
# Except for bug fixes, same as Ali's code
>> require "ali_rizvi_fixed"
=> true
>> t = TextEditor::Document.new
=> #<TextEditor::Document:0x69ab4 @reverted=[], @commands=[], @contents="">
>> t.add_text "Hello World"
=> []
>> t.add_text " Cup"
=> []
>> t.undo
=> [#<Proc:0x00071638@./lib/ali_rizvi_fixed.rb:16>]
>> t.add_text(" Butter")
=> []
>> t.redo
=> nil
>> t.contents
=> "Hello World Butter"
$ ruby memory_test.rb
Starting Memory:
1488
Adding 100 characters, 1 at a time
Current memory footprint:
1548
Adding 1000 characters, 1 at a time
Current memory footprint:
2008
Adding 10000 characters, 1 at a time
Current memory footprint:
7000
Adding 100000 characters, 1 at a time
Current memory footprint:
54160
Took 0.448s to run
$ ruby test/document_test.rb
Loaded suite test/document_test
Started
..........
Finished in 0.002023 seconds.
10 tests, 14 assertions, 0 failures, 0 errors