georgeocrawford
Technical User
Hi,
I would like some advice on improving the speed of my current php script.
It is a script I have written which displays encoded music data on screen like normal printed music.
The script works very well, just a bit slow. Basically it has two main steps:
1) Analyses encoded data, chopping it up into chords and measures. Then adds each note into a huge multi-dimensional array, composed of arrays for each system number, bar number, chord number, etc.
2) Cycles through each chord in the array, printing the relavent characters of my music font with
to a png image at the correct coordinates.
I am testing this at present with pieces about 300 bars long. Stage 1, which creates the 'master array', takes about 0.5 seconds. However, stage 2, which prints characters on the png image, takes about 10 seconds for 300 bars.
My question: Would this be quicker:
1) as above
2) cycle through 'master array' and calculate the coordinates for each chord. Create a 2nd array with 3 entries for each chord: 'x coordinate', 'y coordinate' and 'symbol to be printed'.
3) cycle through this array and use a
loop in conjunction with the
function to print to the image.
(sorry if this is confusing!)
I'm guessing it's the actual
function which slows the whole process down. With that in mind, would this part of my script run faster if it has a very easy array to loop through?
If you can't answer my question, could you perhaps suggest a site I can look at with advice for speeding up php scripts - i.e. which functions to avoid, or when and where not to use loops, arrays, etc.
Thanks for your help.
I would like some advice on improving the speed of my current php script.
It is a script I have written which displays encoded music data on screen like normal printed music.
The script works very well, just a bit slow. Basically it has two main steps:
1) Analyses encoded data, chopping it up into chords and measures. Then adds each note into a huge multi-dimensional array, composed of arrays for each system number, bar number, chord number, etc.
2) Cycles through each chord in the array, printing the relavent characters of my music font with
Code:
ImageTTFText
I am testing this at present with pieces about 300 bars long. Stage 1, which creates the 'master array', takes about 0.5 seconds. However, stage 2, which prints characters on the png image, takes about 10 seconds for 300 bars.
My question: Would this be quicker:
1) as above
2) cycle through 'master array' and calculate the coordinates for each chord. Create a 2nd array with 3 entries for each chord: 'x coordinate', 'y coordinate' and 'symbol to be printed'.
3) cycle through this array and use a
Code:
foreach
Code:
ImageTTFText
(sorry if this is confusing!)
I'm guessing it's the actual
Code:
ImageTTFText
If you can't answer my question, could you perhaps suggest a site I can look at with advice for speeding up php scripts - i.e. which functions to avoid, or when and where not to use loops, arrays, etc.
Thanks for your help.