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 8215ed8

Browse filesBrowse files
Auto-merge pull request #6845 from runrevmark/perf-array_paths
[[ Perf ]] Array access optimizations This patch contains a subset of the patches from #6671 - specifically those aimed at improving the performance of array access. Specifically using an optimized code-path when generating an index name (i.e. a strict integer value), and using on-heap storage for short array paths (those up to 6 elements deep).
2 parents 5c48cca + d40bc41 commit 8215ed8
Copy full SHA for 8215ed8
Expand file treeCollapse file tree

20 files changed

+14118
-229
lines changed

‎benchmarks/_benchmarkrunner.livecodescript

Copy file name to clipboardExpand all lines: benchmarks/_benchmarkrunner.livecodescript
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ private command runSingleCommand pInfo, pScriptFile, pCommand
237237
-- Check the exit status and process for logging.
238238
if tBenchmarkExitStatus is not empty then
239239
write tab & "failed" & return to stdout
240-
write tBenchmarkTimes & return to stderr
240+
write tBenchmarkTimes & return to stdout
241241
return tBenchmarkName & tab & "failed" & return
242242
end if
243+
244+
filter tBenchmarkTimes without "*TIS/TSM*"
243245

244246
local tLog
245247
set the itemDelimiter to tab
+208Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
script "ControlArray"
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+
on BenchmarkArrayBug17434
20+
local tMax
21+
put 100 into tMax
22+
23+
local sA
24+
BenchmarkStartTiming "Bug 17434 - 3-dim matrix"
25+
repeat with i = 1 to tMax
26+
repeat with j = 1 to tMax
27+
repeat with k = 1 to tMax
28+
put "bob,carol,ted,alice" into sA[i][j][k]
29+
end repeat
30+
end repeat
31+
end repeat
32+
BenchmarkStopTiming
33+
end BenchmarkArrayBug17434
34+
35+
on BenchmarkArrayWordCount
36+
/* Generate 10Mb of text from a public domain book */
37+
local tContent
38+
BenchmarkLoadNativeTextFile "the_adventures_of_sherlock_holmes.txt"
39+
repeat while (the number of chars in tContent) < 10 * 1024 * 1024
40+
put the result after tContent
41+
end repeat
42+
43+
local tWordCount, tKeyWords, tResult
44+
BenchmarkStartTiming "WordCount - iterate"
45+
repeat for each word tWord in tContent
46+
end repeat
47+
BenchmarkStopTiming
48+
49+
put empty into tWordCount
50+
BenchmarkStartTiming "WordCount - count"
51+
repeat for each word tWord in tContent
52+
add 1 to tWordCount[tWord]
53+
end repeat
54+
BenchmarkStopTiming
55+
56+
BenchmarkStartTiming "WordCount - keys then sort then combine"
57+
put the keys of tWordCount into tKeyWords
58+
sort tKeyWords
59+
repeat for each line tWord in tKeyWords
60+
put tWord & tab & tWordCount[tWord] & return after tResult
61+
end repeat
62+
BenchmarkStopTiming
63+
64+
put empty into tResult
65+
BenchmarkStartTiming "WordCount - combine then sort"
66+
repeat for each line tWord in tKeyWords
67+
put tWord & tab & tWordCount[tWord] & return after tResult
68+
end repeat
69+
set the itemDelimiter to tab
70+
sort tResult by item 1 of each
71+
BenchmarkStopTiming
72+
end BenchmarkArrayWordCount
73+
74+
on BenchmarkArrayFilterRecords
75+
local tRecords, tFilteredRecords
76+
put _BenchmarkArrayFilterGetRecords() into tRecords
77+
78+
local tWantedColumns
79+
put "First name,Test1,Grade" into tWantedColumns
80+
81+
BenchmarkStartTiming "FilterRecords - stringlist"
82+
repeat 100000 times
83+
get _BenchmarkArrayFilterRecords(tRecords, tWantedColumns)
84+
end repeat
85+
BenchmarkStopTiming
86+
87+
split tWantedColumns by comma as set
88+
BenchmarkStartTiming "FilterRecords - set"
89+
repeat 100000 times
90+
get _BenchmarkArrayFilterRecordsSet(tRecords, tWantedColumns)
91+
end repeat
92+
BenchmarkStopTiming
93+
end BenchmarkArrayFilterRecords
94+
95+
private function _BenchmarkArrayFilterRecords pRecords, pColumnNames
96+
local tFilteredRecords, tFilteredRecord
97+
repeat for each element tRecord in pRecords
98+
repeat for each item tColumnName in pColumnNames
99+
put tRecord[tColumnName] into tFilteredRecord[tColumnName]
100+
end repeat
101+
put tFilteredRecord into \
102+
tFilteredRecords[the number of elements in tFilteredRecords + 1]
103+
end repeat
104+
return tFilteredRecords
105+
end _BenchmarkArrayFilterRecords
106+
107+
private function _BenchmarkArrayFilterRecordsSet pRecords, pColumnNameSet
108+
local tFilteredRecords, tFilteredRecord
109+
repeat for each element tRecord in pRecords
110+
repeat for each key tColumnName in pColumnNameSet
111+
put tRecord[tColumnName] into tFilteredRecord[tColumnName]
112+
end repeat
113+
put tFilteredRecord into \
114+
tFilteredRecords[the number of elements in tFilteredRecords + 1]
115+
end repeat
116+
return tFilteredRecords
117+
end _BenchmarkArrayFilterRecordsSet
118+
119+
private function _BenchmarkArrayFilterGetRecords
120+
local tData
121+
BenchmarkLoadNativeTextFile "example_tsv_records.txt"
122+
put the result into tData
123+
124+
local tColumnNames
125+
put line 1 of tData into tColumnNames
126+
split tColumnNames by tab
127+
128+
local tRecords, tRecordIndex
129+
put 1 into tRecordIndex
130+
repeat for each line tRow in line 2 to -1 of tData
131+
split tRow by tab
132+
repeat with tColumnIndex = 1 to the number of elements in tRow
133+
put tRow[tColumnIndex] into \
134+
tRecords[tRecordIndex][tColumnNames[tColumnIndex]]
135+
end repeat
136+
add 1 to tRecordIndex
137+
end repeat
138+
return tRecords
139+
end _BenchmarkArrayFilterGetRecords
140+
141+
on BenchmarkCKSqrtLoop
142+
BenchmarkStartTiming "CK Sqrt Loop"
143+
local n
144+
repeat with i = 1 to 1000000
145+
add sqrt(i) to n
146+
end repeat
147+
BenchmarkStopTiming
148+
end BenchmarkCKSqrtLoop
149+
150+
on BenchmarkCKAppendFromArray
151+
BenchmarkStartTiming "CK Big List (prepare)"
152+
local tList, tCount
153+
put 9 into tCount
154+
put "apple,banana,carrot,dairy,egg," into tList
155+
repeat tCount - 1 times
156+
put tList after tList
157+
end repeat
158+
BenchmarkStopTiming
159+
160+
local tMod
161+
put the number of items in tList into tMod
162+
163+
local tOutput
164+
BenchmarkStartTiming "CK Big List (non-array)"
165+
repeat with i=0 to 500000-1
166+
put item i*7 mod tMod + 1 of tList & space after tOutput
167+
end repeat
168+
BenchmarkStopTiming
169+
170+
BenchmarkStartTiming "CK Big List (split)"
171+
split tList by comma
172+
BenchmarkStopTiming
173+
174+
BenchmarkStartTiming "CK Big List (array)"
175+
repeat with i=0 to 500000-1
176+
put tList[i*7 mod tMod + 1] & space after tOutput
177+
end repeat
178+
BenchmarkStopTiming
179+
end BenchmarkCKAppendFromArray
180+
181+
on BenchmarkCKLargeText
182+
local x, y, n, i
183+
BenchmarkStartTiming "CK Large Text - 3 (non-cs prepare)"
184+
set the caseSensitive to false
185+
put "fab" into x
186+
put "fzb" into y
187+
put "abcdefghij " into n
188+
repeat with i = 1 to 24
189+
put n & codeunit i mod 10 + 1 of n after n
190+
end repeat
191+
BenchmarkStopTiming
192+
BenchmarkStartTiming "CK Large Text - 3 (non-cs run)"
193+
replace x with y in n
194+
BenchmarkStopTiming
195+
196+
BenchmarkStartTiming "CK Large Text - 3 (cs prepare)"
197+
set the caseSensitive to true
198+
put "fab" into x
199+
put "fzb" into y
200+
put "abcdefghij " into n
201+
repeat with i = 1 to 24
202+
put n & codeunit i mod 10 + 1 of n after n
203+
end repeat
204+
BenchmarkStopTiming
205+
BenchmarkStartTiming "CK Large Text - 3 (cs run)"
206+
replace x with y in n
207+
BenchmarkStopTiming
208+
end BenchmarkCKLargeText
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Last name First name SSN Test1 Test2 Test3 Test4 Final Grade
2+
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0 49.0 D-
3+
Alfred University 123-12-1234 41.0 97.0 96.0 97.0 48.0 D+
4+
Gerty Gramma 567-89-0123 41.0 80.0 60.0 40.0 44.0 C
5+
Android Electric 087-65-4321 42.0 23.0 36.0 45.0 47.0 B-
6+
Bumpkin Fred 456-78-9012 43.0 78.0 88.0 77.0 45.0 A-
7+
Rubble Betty 234-56-7890 44.0 90.0 80.0 90.0 46.0 C-
8+
Noshow Cecil 345-67-8901 45.0 11.0 -1.0 4.0 43.0 F
9+
Buff Bif 632-79-9939 46.0 20.0 30.0 40.0 50.0 B+
10+
Airpump Andrew 223-45-6789 49.0 1.0 90.0 100.0 83.0 A
11+
Backus Jim 143-12-1234 48.0 1.0 97.0 96.0 97.0 A+
12+
Carnivore Art 565-89-0123 44.0 1.0 80.0 60.0 40.0 D+
13+
Dandy Jim 087-75-4321 47.0 1.0 23.0 36.0 45.0 C+
14+
Elephant Ima 456-71-9012 45.0 1.0 78.0 88.0 77.0 B-
15+
Franklin Benny 234-56-2890 50.0 1.0 90.0 80.0 90.0 B-
16+
George Boy 345-67-3901 40.0 1.0 11.0 -1.0 4.0 B
17+
Heffalump Harvey 632-79-9439 30.0 1.0 20.0 30.0 40.0 C

0 commit comments

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