Can I loop in Pashua to return the variables with a boolean of 1?

AppleScript initializes code needed to run ASObjC lazily – it’s not loaded unless and until it’s actually needed. This shows up in a first run, whereas loading of other AppleScript code is done when a host’s AppleScript instance is initialized, and hence before timing begins. That’s why Script Geek shows the first run separately.

Thanks Shane. I’ve noticed this issue before with ASObjC and it’s good to know why this happens.

The speed of my script can be increased by about 2 times, if you remove the redundant code (I have introduced it for indicative purposes only):


set aRecord to {cat:"1", cat4:"0", cat2:"1", cat3:"0", cat78:"1", dog56:"1", Camel_2:1, BigCamel_15:"1"}
set filteredList to {}

-- GET VALID KEYS OF THE RECORD (as LIST OF STRINGS)
set the clipboard to aRecord
set aRecordAsList to the clipboard as list -- EDITED, THANKS TO YVAN KOENIG

-- FILTER THE KEYS LIST and RETURN THE FILTERED LIST
repeat with i from 1 to count aRecordAsList by 2
	if item (i + 1) of aRecordAsList is "1" then set end of filteredList to item i of aRecordAsList
end repeat
return filteredList
--> RESULT: filteredList = {"cat", "cat2", "cat78", "dog56", "BigCamel_15"}

My timing, using Shane Stanley’s “Script Geek” (average time per run):

Peavine - less than 1 msec
Yvan Koenig - 2 msec
KniazidisR - 4,5 msec

KniazidisR. I tested your script on my computer and the results were:

First Run: 19 milliseconds

Repeated Runs: 8 milliseconds

We used different testing procedures, which is one reason for our differing results, although our computers are certainly an additional factor.

I edited the post: the speed increased about 2 times. The first time I compared with the time shown on your computer. What should not be done, since we have different computers.