Thanks John This was an important remark :)
Another remark is that you can also call BLAS for heavy mathematical operations (this is what numpy is doing just calling large fortran library and I do not know for julia but it should be same). And this is easy to do in Pharo. https://thepharo.dev/2021/10/17/binding-an-external-library-into-pharo/ <https://thepharo.dev/2021/10/17/binding-an-external-library-into-pharo/> And now you can just define a lot more easily a new binding. S > On 7 Jan 2022, at 01:24, John Brant <[email protected]> wrote: > > On Jan 6, 2022, at 4:35 PM, Jimmie Houchin <[email protected] > <mailto:[email protected]>> wrote: >> >> No, it is an array of floats. The only integers in the test are in the >> indexes of the loops. >> >> Number random. "generates a float 0.8188008774329387" >> >> So in the randarray below it is an array of 28800 floats. >> >> It just felt so wrong to me that Python3 was so much faster. I don't care if >> Nim, Crystal, Julia are faster. But... >> >> >> I am new to Iceberg and have never shared anything on Github so this is all >> new to me. I uploaded my language test so you can see what it does. It is a >> micro-benchmark. It does things that are not realistic in an app. But it >> does stress a language in areas important to my app. >> >> >> https://github.com/jlhouchin/LanguageTestPharo >> >> >> Let me know if there is anything else I can do to help solve this problem. >> >> I am a lone developer in my spare time. So my apologies for any ugly code. >> > > Are you sure that you have the same algorithm in Python? You are calling sum > and average inside the loop where you are modifying the array: > > 1 to: nsize do: [ :j || n | > n := narray at: j. > narray at: j put: (self loop1calc: i j: j n: n). > nsum := narray sum. > navg := narray average ] > > As a result, you are calculating the sum of the 28,800 size array 28,800 > times (plus another 28,800 times for the average). If I write a similar loop > in Python, it looks like it would take almost 9 minutes on my machine without > using numpy to calculate the sum. The Pharo code takes ~40 seconds. If this > is really how the code should be, then I would change it to not call sum > twice (once for sum and once in average). This will almost result in a 2x > speedup. You could also modify the algorithm to update the nsum value in the > loop instead of summing the array each time. I think the updating would > require <120,000 math ops vs the >1.6 billion that you are performing. > > > John Brant
