Hi,
I tested my latest build on a mate's computer last night. The program works perfectly fine on my machine, but he is getting a framerate of roughly 1 frame per second. The program is a data editor for a football game, with a Graphical User Interface I've designed myself.
Over time I've been tweaking the code to try and rectify the problem. At first, I assumed it was because I was using the Text command a lot for all text. I replaced this with bitmap fonts, which saw a little improvement. I then noticed I was using StringWidth to help me centre text on the x-axis, so I rewrote that to use pre-stored character widths. These two changes increased the frame rate five-fold, which was good (there's no difference on machine, which I believe is because it can handle the Text command properly).
Spec-wise, my machine is Pentium IV 2.2GHz one with 356MB of RAM. His is 1.1GHz with 256MB. Both run XP. He's adamant that he's not running anything in the background. It's also worth pointing out that due to the size of the game data the editor works with, it uses up 100MB of RAM when running.
In trying to find out the problem I wrote a section of code that produced a log file when he viewed a certain screen. This gave me the clock times for all actions when updating a "canvas" (which is an Image, used so that I can redraw sections that need redrawing and keep other things constant), and the screen (which consists of drawing all the necessary canvasses to the screen).
The results of my log file were great - a few milliseconds it took to update an entire canvas, and less to update the screen. Ideal speeds.
His were not so great. When updating the screen it first draws a background - which I'm going to ditch now as it's a bit of a waste, but where my machine takes less than a millisecond, his took 367. The background is an 800x600 bitmap - problem? Most canvases (five were drawn) took less than a millisecond, although one did manage to take 158. One of the quicker canvases is roughly 550x450, the canvas that took the longest is much larger - perhaps closer to the 800x600 of the background (and resolution).
It certainly seems like image size is an issue here - could that be the case? Are there limits when using 2D drawing commands that are hardware related?
Creating a canvas took roughly half a second - this consists of a lot of draw commands to create buttons, text, icons and so forth. Sadly, without the code beside me I can't see what elements are taking longest, but for certain they're taking longer than they should do. When creating a canvas, the program cycles through all the existing Obj (objects such as button, text, item list, graphics etc.) I have created, drawing the necessary ones. There are perhaps 1,000 of these objects, and they are cycled through many times in the loop, checking their "id" field to see if it's the correct one and then skipping on if not. It exits the loop when the correct one is found and dealt with, ignoring the remaining in the loop. I don't see this creating a problem - it's negligible on my machine. Easily tested on his though so I may give that a whirl.
Finally, I'm upgrading to BlitzMax soon and want to port my code. I understand that BlitzMax's 2D capability is better, allowing for alpha, scaling, rotation and so forth in real time (hope I'm not wrong). Would it also be faster? And if so, is it worth my time trying to fix my mate's problem in the meantime or could a simple port be the solution? I think that unlikely, but I can hope.
Sorry for the longwinded nature of the post and the lack of code - I don't have that to hand (I'm in work now) and it's a problem that's been bugging me for weeks, and I hope to eventually find the answer. His machine lies within my target specs so I do want to get it solved.
I tested my latest build on a mate's computer last night. The program works perfectly fine on my machine, but he is getting a framerate of roughly 1 frame per second. The program is a data editor for a football game, with a Graphical User Interface I've designed myself.
Over time I've been tweaking the code to try and rectify the problem. At first, I assumed it was because I was using the Text command a lot for all text. I replaced this with bitmap fonts, which saw a little improvement. I then noticed I was using StringWidth to help me centre text on the x-axis, so I rewrote that to use pre-stored character widths. These two changes increased the frame rate five-fold, which was good (there's no difference on machine, which I believe is because it can handle the Text command properly).
Spec-wise, my machine is Pentium IV 2.2GHz one with 356MB of RAM. His is 1.1GHz with 256MB. Both run XP. He's adamant that he's not running anything in the background. It's also worth pointing out that due to the size of the game data the editor works with, it uses up 100MB of RAM when running.
In trying to find out the problem I wrote a section of code that produced a log file when he viewed a certain screen. This gave me the clock times for all actions when updating a "canvas" (which is an Image, used so that I can redraw sections that need redrawing and keep other things constant), and the screen (which consists of drawing all the necessary canvasses to the screen).
The results of my log file were great - a few milliseconds it took to update an entire canvas, and less to update the screen. Ideal speeds.
His were not so great. When updating the screen it first draws a background - which I'm going to ditch now as it's a bit of a waste, but where my machine takes less than a millisecond, his took 367. The background is an 800x600 bitmap - problem? Most canvases (five were drawn) took less than a millisecond, although one did manage to take 158. One of the quicker canvases is roughly 550x450, the canvas that took the longest is much larger - perhaps closer to the 800x600 of the background (and resolution).
It certainly seems like image size is an issue here - could that be the case? Are there limits when using 2D drawing commands that are hardware related?
Creating a canvas took roughly half a second - this consists of a lot of draw commands to create buttons, text, icons and so forth. Sadly, without the code beside me I can't see what elements are taking longest, but for certain they're taking longer than they should do. When creating a canvas, the program cycles through all the existing Obj (objects such as button, text, item list, graphics etc.) I have created, drawing the necessary ones. There are perhaps 1,000 of these objects, and they are cycled through many times in the loop, checking their "id" field to see if it's the correct one and then skipping on if not. It exits the loop when the correct one is found and dealt with, ignoring the remaining in the loop. I don't see this creating a problem - it's negligible on my machine. Easily tested on his though so I may give that a whirl.
Finally, I'm upgrading to BlitzMax soon and want to port my code. I understand that BlitzMax's 2D capability is better, allowing for alpha, scaling, rotation and so forth in real time (hope I'm not wrong). Would it also be faster? And if so, is it worth my time trying to fix my mate's problem in the meantime or could a simple port be the solution? I think that unlikely, but I can hope.
Sorry for the longwinded nature of the post and the lack of code - I don't have that to hand (I'm in work now) and it's a problem that's been bugging me for weeks, and I hope to eventually find the answer. His machine lies within my target specs so I do want to get it solved.