Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b5b1627

Browse filesBrowse files
Auto-merge pull request #5260 from peter-b/var-access-improvements
Variable access performance improvements Cherry-picked from #5100.
2 parents 2c26d16 + 5d8e0de commit b5b1627
Copy full SHA for b5b1627
Expand file treeCollapse file tree

20 files changed

+882
-547
lines changed
+317Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
script "ControlVariable"
2+
/*
3+
Copyright (C) 2017 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
constant kRepetitions = 100000
20+
21+
private command BenchmarkArrayAccess pOne, pTwo, pThree, pFour
22+
BenchmarkStartTiming "Store[]"
23+
repeat kRepetitions times
24+
put empty into tVar
25+
put 1 into tVar[pOne]
26+
put 2 into tVar[pTwo]
27+
put 3 into tVar[pThree]
28+
put 4 into tVar[pFour]
29+
end repeat
30+
BenchmarkStopTiming
31+
32+
BenchmarkStartTiming "Fetch[]"
33+
repeat kRepetitions times
34+
get tVar[pOne]
35+
get tVar[pTwo]
36+
get tVar[pThree]
37+
get tVar[pFour]
38+
end repeat
39+
BenchmarkStopTiming
40+
41+
BenchmarkStartTiming "Store[][]"
42+
repeat kRepetitions times
43+
put empty into tVar
44+
put 1 into tVar[pOne][pTwo]
45+
put 2 into tVar[pTwo][pThree]
46+
put 3 into tVar[pThree][pFour]
47+
put 4 into tVar[pFour][pOne]
48+
end repeat
49+
BenchmarkStopTiming
50+
51+
BenchmarkStartTiming "Fetch[][]"
52+
repeat kRepetitions times
53+
get tVar[pOne][pTwo]
54+
get tVar[pTwo][pThree]
55+
get tVar[pThree][pFour]
56+
get tVar[pFour][pOne]
57+
end repeat
58+
BenchmarkStopTiming
59+
end BenchmarkArrayAccess
60+
61+
on BenchmarkArrayNameKeys
62+
BenchmarkArrayAccess "one", "two", "three", "four"
63+
end BenchmarkArrayNameKeys
64+
65+
on BenchmarkArrayIndexKeys
66+
BenchmarkArrayAccess 1+0, 2+0, 3+0, 4+0
67+
end BenchmarkArrayIndexKeys
68+
69+
on BenchmarkArrayStringKeys
70+
BenchmarkArrayAccess "on" & "e", "tw" & "o", "thre" & "e", "fou" & "r"
71+
end BenchmarkArrayStringKeys
72+
73+
on BenchmarkVariableFetchLocal
74+
local tVar
75+
76+
local tName1, tName2, tName3, tName4
77+
put "one" into tName1
78+
put "two" into tName1
79+
put "three" into tName1
80+
put "four" into tName1
81+
82+
local tNumber1, tNumber2, tNumber3, tNumber4
83+
put 1 + 0 into tNumber1
84+
put 2 + 0 into tNumber2
85+
put 3 + 0 into tNumber3
86+
put 4 + 0 into tNumber4
87+
88+
local tString1, tString2, tString3, tString4
89+
put "on" & "e" into tString1
90+
put "tw" & "o" into tString2
91+
put "thre" & "e" into tString3
92+
put "fou" & "r" into tString4
93+
94+
local tSeq1_1, tSeq1_2, tSeq1_3, tSeq1_4
95+
put tName1 into tSeq1_1[1]
96+
put tName2 into tSeq1_2[1]
97+
put tName3 into tSeq1_3[1]
98+
put tName4 into tSeq1_4[1]
99+
100+
local tSeq2_1, tSeq2_2, tSeq2_3, tSeq2_4
101+
put tName1 into tSeq2_1[1]
102+
put tName1 into tSeq2_1[2]
103+
put tName2 into tSeq2_2[1]
104+
put tName2 into tSeq2_2[2]
105+
put tName3 into tSeq2_3[1]
106+
put tName3 into tSeq2_3[2]
107+
put tName4 into tSeq2_4[1]
108+
put tName4 into tSeq2_4[2]
109+
110+
put empty into tVar
111+
put 100 into tVar
112+
BenchmarkStartTiming "Get Base"
113+
repeat kRepetitions times
114+
get tVar
115+
get tVar
116+
get tVar
117+
get tVar
118+
end repeat
119+
BenchmarkStopTiming
120+
121+
put empty into tVar
122+
put 100 into tVar[tName1]
123+
put 100 into tVar[tName2]
124+
put 100 into tVar[tName3]
125+
put 100 into tVar[tName4]
126+
BenchmarkStartTiming "Get Base[<name>]"
127+
repeat kRepetitions times
128+
get tVar[tName1]
129+
get tVar[tName2]
130+
get tVar[tName3]
131+
get tVar[tName4]
132+
end repeat
133+
BenchmarkStopTiming
134+
135+
put empty into tVar
136+
put 100 into tVar[tNumber1]
137+
put 100 into tVar[tNumber2]
138+
put 100 into tVar[tNumber3]
139+
put 100 into tVar[tNumber4]
140+
BenchmarkStartTiming "Get Base[<number>]"
141+
repeat kRepetitions times
142+
get tVar[tNumber1]
143+
get tVar[tNumber2]
144+
get tVar[tNumber3]
145+
get tVar[tNumber4]
146+
end repeat
147+
BenchmarkStopTiming
148+
149+
put empty into tVar
150+
put 100 into tVar[tString1]
151+
put 100 into tVar[tString2]
152+
put 100 into tVar[tString3]
153+
put 100 into tVar[tString4]
154+
BenchmarkStartTiming "Get Base[<string>]"
155+
repeat kRepetitions times
156+
get tVar[tString1]
157+
get tVar[tString2]
158+
get tVar[tString3]
159+
get tVar[tString4]
160+
end repeat
161+
BenchmarkStopTiming
162+
163+
put empty into tVar
164+
put 100 into tVar[tSeq1_1]
165+
put 100 into tVar[tSeq1_2]
166+
put 100 into tVar[tSeq1_3]
167+
put 100 into tVar[tSeq1_4]
168+
BenchmarkStartTiming "Get Base[<seq-1>]"
169+
repeat kRepetitions times
170+
get tVar[tSeq1_1]
171+
get tVar[tSeq1_2]
172+
get tVar[tSeq1_3]
173+
get tVar[tSeq1_4]
174+
end repeat
175+
BenchmarkStopTiming
176+
177+
put empty into tVar
178+
put 100 into tVar[tName1][tName1]
179+
put 100 into tVar[tName2][tName2]
180+
put 100 into tVar[tName3][tName3]
181+
put 100 into tVar[tName4][tName4]
182+
BenchmarkStartTiming "Get Base[<name>][<name>]"
183+
repeat kRepetitions times
184+
get tVar[tName1][tName1]
185+
get tVar[tName2][tName2]
186+
get tVar[tName3][tName3]
187+
get tVar[tName4][tName4]
188+
end repeat
189+
BenchmarkStopTiming
190+
191+
put empty into tVar
192+
put 100 into tVar[tNumber1][tNumber1]
193+
put 100 into tVar[tNumber2][tNumber2]
194+
put 100 into tVar[tNumber3][tNumber3]
195+
put 100 into tVar[tNumber4][tNumber4]
196+
BenchmarkStartTiming "Get Base[<number>][<number>]"
197+
repeat kRepetitions times
198+
get tVar[tNumber1][tNumber1]
199+
get tVar[tNumber2][tNumber2]
200+
get tVar[tNumber3][tNumber3]
201+
get tVar[tNumber4][tNumber4]
202+
end repeat
203+
BenchmarkStopTiming
204+
205+
put empty into tVar
206+
put 100 into tVar[tString1][tString1]
207+
put 100 into tVar[tString2][tString2]
208+
put 100 into tVar[tString3][tString3]
209+
put 100 into tVar[tString4][tString4]
210+
BenchmarkStartTiming "Get Base[<string>][<string>]"
211+
repeat kRepetitions times
212+
get tVar[tString1][tString1]
213+
get tVar[tString2][tString2]
214+
get tVar[tString3][tString3]
215+
get tVar[tString4][tString4]
216+
end repeat
217+
BenchmarkStopTiming
218+
219+
put empty into tVar
220+
put 100 into tVar[tSeq2_1]
221+
put 100 into tVar[tSeq2_2]
222+
put 100 into tVar[tSeq2_3]
223+
put 100 into tVar[tSeq2_4]
224+
BenchmarkStartTiming "Get Base[<seq-2>]"
225+
repeat kRepetitions times
226+
get tVar[tSeq2_1]
227+
get tVar[tSeq2_2]
228+
get tVar[tSeq2_3]
229+
get tVar[tSeq2_4]
230+
end repeat
231+
BenchmarkStopTiming
232+
end BenchmarkVariableFetchLocal
233+
234+
on BenchmarkVariableStoreLocal
235+
local tVar, tName, tNumber, tString, tSeq1, tSeq2
236+
put "one" into tName
237+
put 1 + 0 into tNumber
238+
put "on" & "e" into tString
239+
put tName into tSeq1[1]
240+
put tName into tSeq2[1]
241+
put tName into tSeq2[2]
242+
243+
put empty into tVar
244+
put 100 into tVar
245+
BenchmarkStartTiming "Replace Into Base"
246+
repeat kRepetitions times
247+
put 100 into tVar
248+
put 100 into tVar
249+
put 100 into tVar
250+
put 100 into tVar
251+
end repeat
252+
BenchmarkStopTiming
253+
254+
put empty into tVar
255+
put 100 into tVar[tName]
256+
BenchmarkStartTiming "Replace Into Base[<name>]"
257+
repeat kRepetitions times
258+
put 100 into tVar[tName]
259+
end repeat
260+
BenchmarkStopTiming
261+
262+
put empty into tVar
263+
put 100 into tVar[tNumber]
264+
BenchmarkStartTiming "Replace Into Base[<number>]"
265+
repeat kRepetitions times
266+
put 100 into tVar[tNumber]
267+
end repeat
268+
BenchmarkStopTiming
269+
270+
put empty into tVar
271+
put 100 into tVar[tString]
272+
BenchmarkStartTiming "Replace Into Base[<string>]"
273+
repeat kRepetitions times
274+
put 100 into tVar[tString]
275+
end repeat
276+
BenchmarkStopTiming
277+
278+
put empty into tVar
279+
put 100 into tVar[tSeq1]
280+
BenchmarkStartTiming "Replace Into Base[<seq-1>]"
281+
repeat kRepetitions times
282+
put 100 into tVar[tSeq1]
283+
end repeat
284+
BenchmarkStopTiming
285+
286+
put empty into tVar
287+
put 100 into tVar[tName][tName]
288+
BenchmarkStartTiming "Replace Into Base[<name>][<name>]"
289+
repeat kRepetitions times
290+
put 100 into tVar[tName][tName]
291+
end repeat
292+
BenchmarkStopTiming
293+
294+
put empty into tVar
295+
put 100 into tVar[tNumber][tNumber]
296+
BenchmarkStartTiming "Replace Into Base[<number>][<number>]"
297+
repeat kRepetitions times
298+
put 100 into tVar[tNumber][tNumber]
299+
end repeat
300+
BenchmarkStopTiming
301+
302+
put empty into tVar
303+
put 100 into tVar[tString][tString]
304+
BenchmarkStartTiming "Replace Into Base[<string>][<string>]"
305+
repeat kRepetitions times
306+
put 100 into tVar[tString][tString]
307+
end repeat
308+
BenchmarkStopTiming
309+
310+
put empty into tVar
311+
put 100 into tVar[tSeq2]
312+
BenchmarkStartTiming "Replace Into Base[<seq-2>]"
313+
repeat kRepetitions times
314+
put 100 into tVar[tSeq2]
315+
end repeat
316+
BenchmarkStopTiming
317+
end BenchmarkVariableStoreLocal

‎engine/src/cmds.cpp

Copy file name to clipboardExpand all lines: engine/src/cmds.cpp
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,6 @@ Parse_stat MCPut::parse(MCScriptPoint &sp)
982982
return PS_ERROR;
983983
}
984984

985-
MCVarref *t_src_ref, *t_dst_ref;
986-
t_src_ref = source -> getrootvarref();
987-
t_dst_ref = dest -> getrootvarref();
988-
overlap = t_src_ref != NULL && t_dst_ref != NULL && t_src_ref -> rootmatches(t_dst_ref);
989-
990985
return PS_NORMAL;
991986
}
992987

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.