Re: [PHP] Better way to store data in memory?



Richard Davey wrote:
I'm building up some image data in my PHP script (ready for output to
the browser). Having to do some complex per pixel manipulation, which
is fine - but I'm just wondering is there a quicker / more efficient
way of storing the pixel data than in an array?

At the moment I hold it in $array[$x][$y], which makes the drawing
loop painless, but it's creating an array with 307,200 elements which
is proving to be quite slow. As I'm only storing fixed width byte
values is there an alternative method? For example the ability to
read/write to a chunk of memory instead? (so I can read out whole
strips of data rather than one by one?)

I was looking at the Shared Memory functions, but that isn't exactly
what I need (I don't want it shared, I want it process specific)

You could use a string, but I doubt that would be much quicker. Personally I'd be doing this with a temporary file, using fseek to get around.

-Stut

--
http://stut.net/
.



Relevant Pages

  • Re: Better way to store data in memory?
    ... I'm building up some image data in my PHP script (ready for output to ... Having to do some complex per pixel manipulation, ... way of storing the pixel data than in an array? ... I was looking at the Shared Memory functions, ...
    (php.general)
  • Better way to store data in memory?
    ... the browser). ... Having to do some complex per pixel manipulation, ... way of storing the pixel data than in an array? ... I was looking at the Shared Memory functions, ...
    (php.general)
  • Re: Better way to store data in memory?
    ... Is there nothing like streams or a data type that's meant to hold lots of binary data in PHP? ... Having to do some complex per pixel manipulation, ... way of storing the pixel data than in an array? ... I was looking at the Shared Memory functions, ...
    (php.general)
  • Re: <ctype.h> toLower()
    ... > No the strlen in the loop is not an example that has been made efficient. ... > It's not quicker to run on every implementation, maybe it is if a lookup ... > array is used but then your incurring the overhead of the array. ... > No it doesn't rely on anything imagine it is part of a windows program. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Array and resize
    ... I will check whether this is also a quicker way to create such a matrix ... >> You are not creating a 2D array, but an array containing arrays, and you ... >> can't drop these onto a worksheet in this way. ... >>> Sub DumpValues() ...
    (microsoft.public.excel.programming)

Loading