This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathvariable.livecodescript
More file actions
317 lines (280 loc) · 8.33 KB
/
Copy pathvariable.livecodescript
File metadata and controls
317 lines (280 loc) · 8.33 KB
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
306
307
308
309
310
311
312
313
314
315
316
317
script "ControlVariable"
/*
Copyright (C) 2017 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
constant kRepetitions = 100000
private command BenchmarkArrayAccess pOne, pTwo, pThree, pFour
BenchmarkStartTiming "Store[]"
repeat kRepetitions times
put empty into tVar
put 1 into tVar[pOne]
put 2 into tVar[pTwo]
put 3 into tVar[pThree]
put 4 into tVar[pFour]
end repeat
BenchmarkStopTiming
BenchmarkStartTiming "Fetch[]"
repeat kRepetitions times
get tVar[pOne]
get tVar[pTwo]
get tVar[pThree]
get tVar[pFour]
end repeat
BenchmarkStopTiming
BenchmarkStartTiming "Store[][]"
repeat kRepetitions times
put empty into tVar
put 1 into tVar[pOne][pTwo]
put 2 into tVar[pTwo][pThree]
put 3 into tVar[pThree][pFour]
put 4 into tVar[pFour][pOne]
end repeat
BenchmarkStopTiming
BenchmarkStartTiming "Fetch[][]"
repeat kRepetitions times
get tVar[pOne][pTwo]
get tVar[pTwo][pThree]
get tVar[pThree][pFour]
get tVar[pFour][pOne]
end repeat
BenchmarkStopTiming
end BenchmarkArrayAccess
on BenchmarkArrayNameKeys
BenchmarkArrayAccess "one", "two", "three", "four"
end BenchmarkArrayNameKeys
on BenchmarkArrayIndexKeys
BenchmarkArrayAccess 1+0, 2+0, 3+0, 4+0
end BenchmarkArrayIndexKeys
on BenchmarkArrayStringKeys
BenchmarkArrayAccess "on" & "e", "tw" & "o", "thre" & "e", "fou" & "r"
end BenchmarkArrayStringKeys
on BenchmarkVariableFetchLocal
local tVar
local tName1, tName2, tName3, tName4
put "one" into tName1
put "two" into tName1
put "three" into tName1
put "four" into tName1
local tNumber1, tNumber2, tNumber3, tNumber4
put 1 + 0 into tNumber1
put 2 + 0 into tNumber2
put 3 + 0 into tNumber3
put 4 + 0 into tNumber4
local tString1, tString2, tString3, tString4
put "on" & "e" into tString1
put "tw" & "o" into tString2
put "thre" & "e" into tString3
put "fou" & "r" into tString4
local tSeq1_1, tSeq1_2, tSeq1_3, tSeq1_4
put tName1 into tSeq1_1[1]
put tName2 into tSeq1_2[1]
put tName3 into tSeq1_3[1]
put tName4 into tSeq1_4[1]
local tSeq2_1, tSeq2_2, tSeq2_3, tSeq2_4
put tName1 into tSeq2_1[1]
put tName1 into tSeq2_1[2]
put tName2 into tSeq2_2[1]
put tName2 into tSeq2_2[2]
put tName3 into tSeq2_3[1]
put tName3 into tSeq2_3[2]
put tName4 into tSeq2_4[1]
put tName4 into tSeq2_4[2]
put empty into tVar
put 100 into tVar
BenchmarkStartTiming "Get Base"
repeat kRepetitions times
get tVar
get tVar
get tVar
get tVar
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tName1]
put 100 into tVar[tName2]
put 100 into tVar[tName3]
put 100 into tVar[tName4]
BenchmarkStartTiming "Get Base[<name>]"
repeat kRepetitions times
get tVar[tName1]
get tVar[tName2]
get tVar[tName3]
get tVar[tName4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tNumber1]
put 100 into tVar[tNumber2]
put 100 into tVar[tNumber3]
put 100 into tVar[tNumber4]
BenchmarkStartTiming "Get Base[<number>]"
repeat kRepetitions times
get tVar[tNumber1]
get tVar[tNumber2]
get tVar[tNumber3]
get tVar[tNumber4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tString1]
put 100 into tVar[tString2]
put 100 into tVar[tString3]
put 100 into tVar[tString4]
BenchmarkStartTiming "Get Base[<string>]"
repeat kRepetitions times
get tVar[tString1]
get tVar[tString2]
get tVar[tString3]
get tVar[tString4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tSeq1_1]
put 100 into tVar[tSeq1_2]
put 100 into tVar[tSeq1_3]
put 100 into tVar[tSeq1_4]
BenchmarkStartTiming "Get Base[<seq-1>]"
repeat kRepetitions times
get tVar[tSeq1_1]
get tVar[tSeq1_2]
get tVar[tSeq1_3]
get tVar[tSeq1_4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tName1][tName1]
put 100 into tVar[tName2][tName2]
put 100 into tVar[tName3][tName3]
put 100 into tVar[tName4][tName4]
BenchmarkStartTiming "Get Base[<name>][<name>]"
repeat kRepetitions times
get tVar[tName1][tName1]
get tVar[tName2][tName2]
get tVar[tName3][tName3]
get tVar[tName4][tName4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tNumber1][tNumber1]
put 100 into tVar[tNumber2][tNumber2]
put 100 into tVar[tNumber3][tNumber3]
put 100 into tVar[tNumber4][tNumber4]
BenchmarkStartTiming "Get Base[<number>][<number>]"
repeat kRepetitions times
get tVar[tNumber1][tNumber1]
get tVar[tNumber2][tNumber2]
get tVar[tNumber3][tNumber3]
get tVar[tNumber4][tNumber4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tString1][tString1]
put 100 into tVar[tString2][tString2]
put 100 into tVar[tString3][tString3]
put 100 into tVar[tString4][tString4]
BenchmarkStartTiming "Get Base[<string>][<string>]"
repeat kRepetitions times
get tVar[tString1][tString1]
get tVar[tString2][tString2]
get tVar[tString3][tString3]
get tVar[tString4][tString4]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tSeq2_1]
put 100 into tVar[tSeq2_2]
put 100 into tVar[tSeq2_3]
put 100 into tVar[tSeq2_4]
BenchmarkStartTiming "Get Base[<seq-2>]"
repeat kRepetitions times
get tVar[tSeq2_1]
get tVar[tSeq2_2]
get tVar[tSeq2_3]
get tVar[tSeq2_4]
end repeat
BenchmarkStopTiming
end BenchmarkVariableFetchLocal
on BenchmarkVariableStoreLocal
local tVar, tName, tNumber, tString, tSeq1, tSeq2
put "one" into tName
put 1 + 0 into tNumber
put "on" & "e" into tString
put tName into tSeq1[1]
put tName into tSeq2[1]
put tName into tSeq2[2]
put empty into tVar
put 100 into tVar
BenchmarkStartTiming "Replace Into Base"
repeat kRepetitions times
put 100 into tVar
put 100 into tVar
put 100 into tVar
put 100 into tVar
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tName]
BenchmarkStartTiming "Replace Into Base[<name>]"
repeat kRepetitions times
put 100 into tVar[tName]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tNumber]
BenchmarkStartTiming "Replace Into Base[<number>]"
repeat kRepetitions times
put 100 into tVar[tNumber]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tString]
BenchmarkStartTiming "Replace Into Base[<string>]"
repeat kRepetitions times
put 100 into tVar[tString]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tSeq1]
BenchmarkStartTiming "Replace Into Base[<seq-1>]"
repeat kRepetitions times
put 100 into tVar[tSeq1]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tName][tName]
BenchmarkStartTiming "Replace Into Base[<name>][<name>]"
repeat kRepetitions times
put 100 into tVar[tName][tName]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tNumber][tNumber]
BenchmarkStartTiming "Replace Into Base[<number>][<number>]"
repeat kRepetitions times
put 100 into tVar[tNumber][tNumber]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tString][tString]
BenchmarkStartTiming "Replace Into Base[<string>][<string>]"
repeat kRepetitions times
put 100 into tVar[tString][tString]
end repeat
BenchmarkStopTiming
put empty into tVar
put 100 into tVar[tSeq2]
BenchmarkStartTiming "Replace Into Base[<seq-2>]"
repeat kRepetitions times
put 100 into tVar[tSeq2]
end repeat
BenchmarkStopTiming
end BenchmarkVariableStoreLocal