07-08-2024 03:26 AM
Apologies in advance for the image quality. I wanted to ask what is the correct way to execute the code. Thank you!
07-08-2024 03:37 AM
Both are OK.
In this situation, I'd prefer converting in the loop (bottom), because the array you're building is smaller:
top: Building a 8000 byte array, converting it to 4000 byte.
bottom: Converting 8 bytes to 4, building a 4000 byte array.
So, the bottom one will be easier on memory allocation.
I doubt you'll notice the difference in practice (although you can benchmark the two).
07-08-2024 07:46 AM
wiebe@CARYA wrote:
Both are OK.
In this situation, I'd prefer converting in the loop (bottom), because the array you're building is smaller:
top: Building a 8000 byte array, converting it to 4000 byte.
bottom: Converting 8 bytes to 4, building a 4000 byte array.
So, the bottom one will be easier on memory allocation.
I doubt you'll notice the difference in practice (although you can benchmark the two).
There are Tools that will help! Right in the Tools Menu!
You can:
By the way, that For Loop could be "Parallelized" even though you might get a warning. The PRNG will always execute the right number of times so you'll always get the same values given the same initial seed value but, the iterations may not be sequential changing the order or the values in the array.
07-08-2024 09:11 AM - edited 07-08-2024 09:25 AM
@maxnoder1995 wrote:
Apologies in advance for the image quality. I wanted to ask what is the correct way to execute the code. Thank you!
Most likely the compiler will rearrange the code for most optimal behavior use and it really does not matter once debugging is disabled. (when debugging is enabled, we need to be able to probe the array after the loop and there will be a slight difference.).
Still 1k points is trivial. Start worrying once you deal with a few orders of magnitude more points. Note that you also could do the addition inside the loop.
(I am worried that if you even have problems taking screenshots or properly cropping pictures, you might not be very computer savvy and you are going down the rabbit hole trying to worry about things that don't really matter.. Focus on getting the right result with scalable and easy to read code the rest does not matter here)
I am also pretty sure that parallelizing the FOR loop would actually slow you down. Only do that if the code inside the loop is heavy.
Don't forget that the array indicator also has a 4k transfer buffer.