Mirage Source http://web.miragesource.net/forums/ |
|
A little something about timers http://web.miragesource.net/forums/viewtopic.php?f=210&t=1111 |
Page 1 of 1 |
Author: | Joost [ Tue Jan 09, 2007 7:16 pm ] |
Post subject: | A little something about timers |
The example. 2 timers. Intervals at 500, and 1000 The one with 500 has this code: Code: Call Download(Porn) The one with 1000 has this code: Code: Call Upload(Porn) Timers use ram and CPU. We don't want that. So, we fix that. Inside the timer with the 500 interval, we Code: Dim Variable as Boolean and we set Code: Variable = !Variable Then we just Code: Call Download(Porn) like before. However, now we add something else to that sub too : Code: If Variable = True Then Call Upload(Porn) End If Now we delete the timer with an interval of 1000, and we're done. We've replaced a timer, and it's sub with just an if statement, a boolean, and the Code: Variable = !Variable part.
Simple, yet effective. |
Author: | Bradyok [ Tue Jan 16, 2007 1:22 am ] |
Post subject: | |
Thanks man, this is a great way to download porn! |
Author: | Robin [ Tue Dec 25, 2007 2:52 am ] |
Post subject: | Re: A little something about timers |
Happy anniversary. |
Author: | Lea [ Tue Dec 25, 2007 6:40 am ] |
Post subject: | Re: A little something about timers |
I've done some interesting reading just now. AS it turns out, VB timers have a 10ms (up to 56 ms) resolution, which makes them not very accurate. Also, VB timers are, no matter how many you add, all taken from the same timer internally, which is housed in the VB runtime. When a MsgBox is called, the rest of the program halts EXCEPT the timers, which continue as normal, which can cause problems, including crashing the VB IDE should an error occur when a timer causes an error when halted at a MsgBox. Apparently a work-around for this is to use the Win32 MessageBox API instead, which does halt timers. http://www.vbaccelerator.com/home/vb/co ... rticle.asp http://www.msfn.org/board/lofiversion/i ... 68771.html http://www.devx.com/vb2themax/Tip/18324 edit: Just wanted to add: Timers need to be placed on a form to function, and all controls take up overhead in the form of EXE bloat. Why do you think the MS EXEs are so huge? Controls. |
Author: | Lea [ Tue Dec 25, 2007 4:40 pm ] |
Post subject: | Re: A little something about timers |
Just did a test. An empty project with no controls or anything takes up 16384 bytes. A project with 20 timers and nothing else takes up 20480 bytes. 20480 -16384 ------- 4096 bytes of timers 4096 bytes / 20 timer = 204.8 bytes per timer Obviously, the windows filesize measurer isnt too acurate, and that's where the .8 comes in. If I were to add many more timers, and do the math, I would get a closer number. But we can say simply adding a timer control to a form adds 205 bytes to your project. As for CPU usage, I can do nothing but speculate. Since I read that the timer control all pulls off the same timer inside, I assume that the overhead for the first timer is the largest, but additional timers after that don't suffer as much. There still has to be some overhead, though... I think it's negligible. |
Author: | Lea [ Tue Dec 25, 2007 8:04 pm ] |
Post subject: | Re: A little something about timers |
I'm talking file size. It's probably the size on disk, because when I added one timer, there was no size change. When I added 20, however, there was quite a significant one (one that should have been detected with only one timer) Also, what I said is purely speculation. Don't quote me on it. Do some research for yourself and try it out |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |