Will calling ksort() on an array speed up it's access?
For example, I have the array $file_index, which is accessed by a key (the
entry id) and has two sub elements in a one dimensional array (line number
of the start of the entry in the file, and the byte offset of the start of
the entry).
so, I might have an array that can be represented thus:
{
2 => {1, 100),
4 => (30, 556),
10 => (376, 2637),
...
}
These usually have thousands of entries, so the arrays are quite large, and
anything I can do to speed up the data access will be big.
One file, contains under 10MB of data in under 2000 entries, the next
contains about 35MB of data in around 8000 entries, and the final contains
about 125MB of data in 20000+ entries, and I'm noticing significant lag on
the latter, so I was hoping to find a way to speed up the array access.
Thanks for the help
-Jim Stapleton
For example, I have the array $file_index, which is accessed by a key (the
entry id) and has two sub elements in a one dimensional array (line number
of the start of the entry in the file, and the byte offset of the start of
the entry).
so, I might have an array that can be represented thus:
{
2 => {1, 100),
4 => (30, 556),
10 => (376, 2637),
...
}
These usually have thousands of entries, so the arrays are quite large, and
anything I can do to speed up the data access will be big.
One file, contains under 10MB of data in under 2000 entries, the next
contains about 35MB of data in around 8000 entries, and the final contains
about 125MB of data in 20000+ entries, and I'm noticing significant lag on
the latter, so I was hoping to find a way to speed up the array access.
Thanks for the help
-Jim Stapleton
Comment