compileIt for revolution?
Alex Tweedly
alex at tweedly.net
Sun Jun 26 20:23:27 EDT 2005
I sent this message Saturday, and it just came back to me as bounced
(because the list-server was off-line).
So here it is again - with an addendum ...
>Geoff Canyon wrote:
>
>
>
>>On Jun 24, 2005, at 4:26 AM, Jon wrote:
>>
>>
>>
>>>With all due respect, Jim, if you are trying to do even simple math
>>>on a large array of numbers (like computing a histogram of image
>>>data), Rev is simply too slow to use. It has nothing to do with
>>>data structures: it has to do with slow pCode trying to run tight
>>>loops.
>>>
>>>
>>As stated previously, I cannot accept this statement/conclusion
>>without seeing the code in question. There are simply too many ways
>>to write slow code to assume that Rev can't do a task based solely on
>>a very general description -- unless the description involves real
>>time first-person gaming ;-)
>>
>>
>
>Well, the problem Jon mentioned (histogram of image data) is pretty well
>defined. To be usable, you need to do it for reasonable size pictures in
>less than 1-2 secs. (where "reasonable" is defined to be whatever your camera takes, since
>that's the data you're most likely to want a histogram of, in
>preparation for controlling contrast, colour balance, etc.)
>
>Naive code to do it is something like
>
>
>> put 0 into count
>> repeat for each char c in the imageData of img "Image"
>> switch count mod 4
>> case 0
>> break
>> case 1
>> add 1 to tRed[chartonum(c)]
>> break
>> case 2
>> add 1 tGreen[chartonum(c)]
>> break
>> case 3
>> add 1 to tBlue[chartonum(c)]
>>-- put -1 into count
>> break
>> default
>> put "error " && count into msg
>> end switch
>> add 1 to count
>> end repeat
>> displayHistogram tRed, tGreen, tBlue
>>
>>
>
>For me, on my fairly puny laptop, that takes around 175 seconds, so I
>only need a 300x speedup.
>
>
And with an equally naive C external, it takes about 400 ms - about a
quarter of which is formatting the result back suitable for Rev, and
then Rev reformatting it suitable for my displayHistogram function.
I tried some other Transcript approaches (I think the fastest one I
found was
replacing the unused bytes by 'cr's
sorting lines by char 1 of each (remembering to set caseSensitive to
true first !!)
scanning through the lines, counting as you go until char 1 changes,
then putting that count into the appropriate array element
and repeat the sort + scan for char 2 and char 3 in turn
This brought the time needed for a small photo (800x600) from 14 secs
down to 7; unfortunately on a large photo that took more than 5 minutes,
and increased my Windows Virtual Memory twice. But even on the small
photo the time taken is still enough to make it unusable.
--
Alex Tweedly http://www.tweedly.net
-------------- next part --------------
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.1/28 - Release Date: 24/06/2005
More information about the use-livecode
mailing list