Computer Science Canada menu runs slow, but fast sometimes |
Author: | michaelp [ Mon Mar 16, 2009 3:53 pm ] |
Post subject: | menu runs slow, but fast sometimes |
I have a menu for my G9 final project. Everything seems to working okay, but the menu runs really slow sometimes, and other times, very fast, and I have no idea as to why. Most of the time it will run slower, but it will speed up occasionally. I am gonna attach the files and images necessary to run the menu, could someone take a look at it? |
Author: | BigBear [ Mon Mar 16, 2009 4:40 pm ] |
Post subject: | Re: menu runs slow, but fast sometimes |
I didn't find it slow. I did find it annoying that is exits if incorrect input. Also you should use setscreen("noecho") |
Author: | michaelp [ Mon Mar 16, 2009 5:48 pm ] |
Post subject: | RE:menu runs slow, but fast sometimes |
Really? What was the number that was displayed on the bottom right hand corner of the screen? And for me, it will run fast occasionally. Like, I will work with it for 5 min, and when I run it, it will be slow. But sometimes, when I come back to it, it will be a helluva lot faster than before. Next time I work on it, it will be slow again. And I'll fix the exiting thing. |
Author: | Wolf_Destiny [ Mon Mar 16, 2009 6:28 pm ] |
Post subject: | Re: menu runs slow, but fast sometimes |
I found that a fairly hack way of speeding up turing's image loading is to load them all at the beginning of the program. I'd assume that it loads them into the ram instead of having to read from the hard drive each time. So maybe that's an option? |
Author: | BigBear [ Mon Mar 16, 2009 6:43 pm ] |
Post subject: | RE:menu runs slow, but fast sometimes |
The number starts at 0 then goes to 86 then I hit number 1 and return it is 45 then 86. |
Author: | michaelp [ Mon Mar 16, 2009 6:57 pm ] |
Post subject: | RE:menu runs slow, but fast sometimes |
Holy crap. The fastest it's been on my computer is 50 something, and that's when it's going fast. For me, it is usually at 15 or 16. And Wolf_Destiny: my images are loaded at the start of the program. |
Author: | copthesaint [ Mon Mar 16, 2009 8:28 pm ] |
Post subject: | RE:menu runs slow, but fast sometimes |
Well Michaelp If you run Turing a bunch of times, It will eventually take up more and more of your computers ram. Eventually it can take up to 2 GB of ram and more. Sooner or later you will eventually have to press Ctrl-Alt-Delete and end the Turing process. That will eliminate the build up of ram for Turing, Then run Turing again. For me I don't have to worry about this as much with 4 GB of ram on my laptop, but for computers with less, well Turing can take up a lot of ram. |
Author: | michaelp [ Tue Mar 17, 2009 8:43 am ] |
Post subject: | RE:menu runs slow, but fast sometimes |
I see. When I run the menu while looking at the RAM usage for the Turing process, it ate up about 6 more megabytes of RAM/second. ![]() I don't know if the school computers will be able to handle it! Does anyone know why though? I free the rotatedCD pic at the end of each loop. ![]() |
Author: | copthesaint [ Tue Mar 17, 2009 9:11 am ] |
Post subject: | RE:menu runs slow, but fast sometimes |
You free the rotatedCD pic after each loop because you don't want to declare a new picture for each change in angle. If you remove The Pic.Free (CDROTATED) then for every angle it changes you will create a new picture, then you will max out you max number of picture witch is 1000 btw. |
Author: | michaelp [ Tue Mar 17, 2009 10:55 am ] | ||
Post subject: | Re: menu runs slow, but fast sometimes | ||
So, are you saying something like creating an array at the beginning of the program, with all the necessary rotated CD's would be better? I just did that. Here is the new code for menu.t:
|
Author: | copthesaint [ Tue Mar 17, 2009 11:19 am ] |
Post subject: | RE:menu runs slow, but fast sometimes |
No I didn't What you had before was right I was just trying to explain why you use Pic.Free |
Author: | The_Bean [ Wed Mar 18, 2009 6:21 pm ] |
Post subject: | Re: menu runs slow, but fast sometimes |
On my computer your original programs runs around 62 The update you posted ran around 18 Using some of my tricks I got it to average at 124 and sometimes peek at 152 So it is possible to greatly increase the speed. 1)Creating and freeing images takes a lot of time. So hold the rotated CD images in an array. 2)Avoid using processes, use Input.KeyDown() to get the input instead. 3)picMerge is really really slow. Change the image backgrounds from white to grey and use picCopy instead. 4)View.UpdateArea() works great for speeding things up, but not if you use it more than once in a loop, just use View.Update. |
Author: | michaelp [ Thu Mar 19, 2009 10:08 am ] | ||||
Post subject: | RE:menu runs slow, but fast sometimes | ||||
The update ran around 18 because of this line:
That means it was working. ![]() Out of the things you just suggested, I did the array thing. I'll see what I can do to implement the other things. edit: Okay, I've done most of the things you said, and I got it to run at 100. I didn't change the View.UpdateArea's because: 1. They are used for effect. 2. There wasn't a significant speed-up.(or any,really) Also, I tried to picCopy the rotating CD's: didn't work out well! But everything else is working great, got rid of the process and what not. Here is the new code:(The Time.DelaySinceLast line is commented out)
|
Author: | The_Bean [ Thu Mar 19, 2009 11:19 am ] |
Post subject: | Re: menu runs slow, but fast sometimes |
You can get even faster by using the picCopy on the CD, but you need to set the transparent colour of the main CD image to grey before you rotate it. This way the new white sections it makes will actually be grey. It made for a gain 20 on my comp. |
Author: | michaelp [ Thu Mar 19, 2009 11:37 am ] |
Post subject: | RE:menu runs slow, but fast sometimes |
Awesome, doing that gets it up to 115-120. Thanks for the help, I don't need it going any faster now. ![]() |