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.

[[ Perf ]] General features and improvements aimed at optimization #6671

Open
wants to merge 19 commits into
base: develop
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion 4 benchmarks/_benchmarkrunner.livecodescript
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ private command runSingleCommand pInfo, pScriptFile, pCommand
-- Check the exit status and process for logging.
if tBenchmarkExitStatus is not empty then
write tab & "failed" & return to stdout
write tBenchmarkTimes & return to stderr
write tBenchmarkTimes & return to stdout
return tBenchmarkName & tab & "failed" & return
end if

filter tBenchmarkTimes without "*TIS/TSM*"

local tLog
set the itemDelimiter to tab
Expand Down
116 changes: 116 additions & 0 deletions 116 benchmarks/lcs/array/literals.livecodescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
script "ArrayLiterals"
/*
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 = 1000000

on BenchmarkSequenceLiterals
local tLegacyLiteral, tLiteral

BenchmarkStartTiming "LegacyConstantCreation"
repeat kRepetitions times
put empty into tLegacyLiteral
put true into tLegacyLiteral[1]
put 1 into tLegacyLiteral[2]
put pi into tLegacyLiteral[3]
put "Hello" into tLegacyLiteral[4]
put false into tLegacyLiteral[5]
put 2 into tLegacyLiteral[6]
put pi into tLegacyLiteral[7]
put "World!" into tLegacyLiteral[8]
put it into tLegacyLiteral[9]
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "LegacyDynamicCreation"
repeat kRepetitions times
put empty into tLegacyLiteral
put _Identity(true) into tLegacyLiteral[1]
put _Identity(1) into tLegacyLiteral[2]
put _Identity(pi) into tLegacyLiteral[3]
put _Identity("Hello") into tLegacyLiteral[4]
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "ConstantCreation"
repeat kRepetitions times
put [ true, 1, pi, "Hello", false, 2, pi, "World!", [ true, 1, pi, "Hello", false, 2, pi, "World!" ] ] into tLiteral
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "DynamicCreation"
repeat kRepetitions times
put [ _Identity(true), _Identity(1), _Identity(pi), _Identity("Hello") ] into tLiteral
end repeat
BenchmarkStopTiming

local tConstantLiteral
put [ true, 1, pi, "Hello", false, 2, pi, "World!", [ true, 1, pi, "Hello", false, 2, pi, "World!" ] ] into tConstantLiteral
BenchmarkStartTiming "ConstantComparison"
repeat kRepetitions times
get tConstantLiteral is [ true, 1, pi, "Hello", false, 2, pi, "World!", [ true, 1, pi, "Hello", false, 2, pi, "World!" ] ]
end repeat
BenchmarkStopTiming

local tDynamicLiteral
put [ _Identity(true), _Identity(1), _Identity(pi), _Identity("Hello") ] into tDynamicLiteral
BenchmarkStartTiming "DynamicComparison"
repeat kRepetitions times
get tDynamicLiteral is [ true, 1, pi, "Hello" ]
end repeat
BenchmarkStopTiming
end BenchmarkSequenceLiterals

on BenchmarkArrayLiterals
local tLegacyLiteral, tLiteral

BenchmarkStartTiming "LegacyConstantCreation"
repeat kRepetitions times
put empty into tLegacyLiteral
put true into tLegacyLiteral["true"]
put 1 into tLegacyLiteral["1"]
put pi into tLegacyLiteral["pi"]
put "Hello" into tLegacyLiteral["Hello"]
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "LegacyDynamicCreation"
repeat kRepetitions times
put empty into tLegacyLiteral
put _Identity(true) into tLegacyLiteral["true"]
put _Identity(1) into tLegacyLiteral["1"]
put _Identity(pi) into tLegacyLiteral["pi"]
put _Identity("Hello") into tLegacyLiteral["Hello"]
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "ConstantCreation"
repeat kRepetitions times
put { "true": true, "1": 1, "pi": pi, "Hello": "Hello" } into tLiteral
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "DynamicCreation"
repeat kRepetitions times
put { "true": _Identity(true), "1": _Identity(1), "pi": _Identity(pi), "Hello": _Identity("Hello") } into tLiteral
end repeat
BenchmarkStopTiming
end BenchmarkArrayLiterals

private function _Identity pValue
return pValue
end _Identity
208 changes: 208 additions & 0 deletions 208 benchmarks/lcs/control/array.livecodescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
script "ControlArray"
/*
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/>. */

on BenchmarkArrayBug17434
local tMax
put 100 into tMax

local sA
BenchmarkStartTiming "Bug 17434 - 3-dim matrix"
repeat with i = 1 to tMax
repeat with j = 1 to tMax
repeat with k = 1 to tMax
put "bob,carol,ted,alice" into sA[i][j][k]
end repeat
end repeat
end repeat
BenchmarkStopTiming
end BenchmarkArrayBug17434

on BenchmarkArrayWordCount
/* Generate 10Mb of text from a public domain book */
local tContent
BenchmarkLoadNativeTextFile "the_adventures_of_sherlock_holmes.txt"
repeat while (the number of chars in tContent) < 10 * 1024 * 1024
put the result after tContent
end repeat

local tWordCount, tKeyWords, tResult
BenchmarkStartTiming "WordCount - iterate"
repeat for each word tWord in tContent
end repeat
BenchmarkStopTiming

put empty into tWordCount
BenchmarkStartTiming "WordCount - count"
repeat for each word tWord in tContent
add 1 to tWordCount[tWord]
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "WordCount - keys then sort then combine"
put the keys of tWordCount into tKeyWords
sort tKeyWords
repeat for each line tWord in tKeyWords
put tWord & tab & tWordCount[tWord] & return after tResult
end repeat
BenchmarkStopTiming

put empty into tResult
BenchmarkStartTiming "WordCount - combine then sort"
repeat for each line tWord in tKeyWords
put tWord & tab & tWordCount[tWord] & return after tResult
end repeat
set the itemDelimiter to tab
sort tResult by item 1 of each
BenchmarkStopTiming
end BenchmarkArrayWordCount

on BenchmarkArrayFilterRecords
local tRecords, tFilteredRecords
put _BenchmarkArrayFilterGetRecords() into tRecords

local tWantedColumns
put "First name,Test1,Grade" into tWantedColumns

BenchmarkStartTiming "FilterRecords - stringlist"
repeat 100000 times
get _BenchmarkArrayFilterRecords(tRecords, tWantedColumns)
end repeat
BenchmarkStopTiming

split tWantedColumns by comma as set
BenchmarkStartTiming "FilterRecords - set"
repeat 100000 times
get _BenchmarkArrayFilterRecordsSet(tRecords, tWantedColumns)
end repeat
BenchmarkStopTiming
end BenchmarkArrayFilterRecords

private function _BenchmarkArrayFilterRecords pRecords, pColumnNames
local tFilteredRecords, tFilteredRecord
repeat for each element tRecord in pRecords
repeat for each item tColumnName in pColumnNames
put tRecord[tColumnName] into tFilteredRecord[tColumnName]
end repeat
put tFilteredRecord into \
tFilteredRecords[the number of elements in tFilteredRecords + 1]
end repeat
return tFilteredRecords
end _BenchmarkArrayFilterRecords

private function _BenchmarkArrayFilterRecordsSet pRecords, pColumnNameSet
local tFilteredRecords, tFilteredRecord
repeat for each element tRecord in pRecords
repeat for each key tColumnName in pColumnNameSet
put tRecord[tColumnName] into tFilteredRecord[tColumnName]
end repeat
put tFilteredRecord into \
tFilteredRecords[the number of elements in tFilteredRecords + 1]
end repeat
return tFilteredRecords
end _BenchmarkArrayFilterRecordsSet

private function _BenchmarkArrayFilterGetRecords
local tData
BenchmarkLoadNativeTextFile "example_tsv_records.txt"
put the result into tData

local tColumnNames
put line 1 of tData into tColumnNames
split tColumnNames by tab

local tRecords, tRecordIndex
put 1 into tRecordIndex
repeat for each line tRow in line 2 to -1 of tData
split tRow by tab
repeat with tColumnIndex = 1 to the number of elements in tRow
put tRow[tColumnIndex] into \
tRecords[tRecordIndex][tColumnNames[tColumnIndex]]
end repeat
add 1 to tRecordIndex
end repeat
return tRecords
end _BenchmarkArrayFilterGetRecords

on BenchmarkCKSqrtLoop
BenchmarkStartTiming "CK Sqrt Loop"
local n
repeat with i = 1 to 1000000
add sqrt(i) to n
end repeat
BenchmarkStopTiming
end BenchmarkCKSqrtLoop

on BenchmarkCKAppendFromArray
BenchmarkStartTiming "CK Big List (prepare)"
local tList, tCount
put 9 into tCount
put "apple,banana,carrot,dairy,egg," into tList
repeat tCount - 1 times
put tList after tList
end repeat
BenchmarkStopTiming

local tMod
put the number of items in tList into tMod

local tOutput
BenchmarkStartTiming "CK Big List (non-array)"
repeat with i=0 to 500000-1
put item i*7 mod tMod + 1 of tList & space after tOutput
end repeat
BenchmarkStopTiming

BenchmarkStartTiming "CK Big List (split)"
split tList by comma
BenchmarkStopTiming

BenchmarkStartTiming "CK Big List (array)"
repeat with i=0 to 500000-1
put tList[i*7 mod tMod + 1] & space after tOutput
end repeat
BenchmarkStopTiming
end BenchmarkCKAppendFromArray

on BenchmarkCKLargeText
local x, y, n, i
BenchmarkStartTiming "CK Large Text - 3 (non-cs prepare)"
set the caseSensitive to false
put "fab" into x
put "fzb" into y
put "abcdefghij " into n
repeat with i = 1 to 24
put n & codeunit i mod 10 + 1 of n after n
end repeat
BenchmarkStopTiming
BenchmarkStartTiming "CK Large Text - 3 (non-cs run)"
replace x with y in n
BenchmarkStopTiming

BenchmarkStartTiming "CK Large Text - 3 (cs prepare)"
set the caseSensitive to true
put "fab" into x
put "fzb" into y
put "abcdefghij " into n
repeat with i = 1 to 24
put n & codeunit i mod 10 + 1 of n after n
end repeat
BenchmarkStopTiming
BenchmarkStartTiming "CK Large Text - 3 (cs run)"
replace x with y in n
BenchmarkStopTiming
end BenchmarkCKLargeText
17 changes: 17 additions & 0 deletions 17 benchmarks/lcs/control/example_tsv_records.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Last name First name SSN Test1 Test2 Test3 Test4 Final Grade
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0 49.0 D-
Alfred University 123-12-1234 41.0 97.0 96.0 97.0 48.0 D+
Gerty Gramma 567-89-0123 41.0 80.0 60.0 40.0 44.0 C
Android Electric 087-65-4321 42.0 23.0 36.0 45.0 47.0 B-
Bumpkin Fred 456-78-9012 43.0 78.0 88.0 77.0 45.0 A-
Rubble Betty 234-56-7890 44.0 90.0 80.0 90.0 46.0 C-
Noshow Cecil 345-67-8901 45.0 11.0 -1.0 4.0 43.0 F
Buff Bif 632-79-9939 46.0 20.0 30.0 40.0 50.0 B+
Airpump Andrew 223-45-6789 49.0 1.0 90.0 100.0 83.0 A
Backus Jim 143-12-1234 48.0 1.0 97.0 96.0 97.0 A+
Carnivore Art 565-89-0123 44.0 1.0 80.0 60.0 40.0 D+
Dandy Jim 087-75-4321 47.0 1.0 23.0 36.0 45.0 C+
Elephant Ima 456-71-9012 45.0 1.0 78.0 88.0 77.0 B-
Franklin Benny 234-56-2890 50.0 1.0 90.0 80.0 90.0 B-
George Boy 345-67-3901 40.0 1.0 11.0 -1.0 4.0 B
Heffalump Harvey 632-79-9439 30.0 1.0 20.0 30.0 40.0 C
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.