Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Performance issue in the loop.

by harangzsolt33 (Chaplain)
on Feb 24, 2022 at 13:45 UTC ( [id://11141615]=note: print w/replies, xml ) Need Help??


in reply to Performance issue in the loop.

I have noticed that working with arrays is slow in Perl, but if there is any way you could rewrite your code so that instead of an array of numbers, you use a string (an array of characters), that would make it faster, I think. Use vec($STRING, $PTR, 8) = $NewValue to change values within the array OR $MyValue = vec($STRING, $PTR, 8) to read values from the string. The problem is that a character can only go from 0 to 255, so if you want a larger range, you would use 16-bit ints or 32-bit ints to store the numbers. If you use 32-bit ints, vec($STRING, $PTR, 32) will do the work fine. The string will be 4X longer, and keep in mind that when $PTR = 4, it points to the 5th 32-bit int, not to the 2nd 32-bit int.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11141615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found