From WikiChip
Editing mirc/optimization

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 170: Line 170:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
As you can see, in this example each chunk does 1,000 loops, and then sets a timer to run the next chunk. The number of iterations per chunk will depend on the CPU load of the stuff in the loop - you may need to experiment to determine the optimum number of iterations per chunk (bearing in mind that it may run on PCs of different CPU powers). Clearly you want to keep the iterations small enough that mIRC continues to feel responsive, but you don't want to slow it up by having too many small chunks being queued on the timer.
+
The number of iterations per chunk will depend on the CPU load of the stuff in the loop - you may need to experiment to determine the optimum number of iterations per chunk (bearing in mind that it may run on PCs of different CPU powers). Clearly you want to keep the iterations small enough that mIRC continues to feel responsive, but you don't want to slow it up by having too many small chunks being queued on the timer.
  
On a Core i7 laptop, the first example takes c. 10.8s during which mIRC is unresponsive, and the second takes c. 19.8s but remains very responsive to e.g. keystrokes - however there is an overhead of c. 9s for 1,000 chunks. If one million loops takes 11s, then a chunk of a thousand loops will take c. 11ms which is a lot smaller than needed to keep mIRC responsive. If we assume that to keep mIRC feeling responsive we need to process other activities (say) every 100ms, this suggests that we should be able to run 100 chunks of 10,000 iterations rather than 1,000 of 1,000, and by doing this reduce the overhead of chunking by a factor of 10, which should give us a run time of c. 11.7s - and when I tried it mIRC still felt pretty responsive e.g. to keystrokes, and it did indeed take c. 11.7s to run.  
+
As you can see each chunk does 1,000 loops, and then sets a timer to run the next chunk. On a Core i7 laptop, the first example takes c. 10.8s during which mIRC is unresponsive, and the second takes c. 19.8s but remains very responsive to e.g. keystrokes - however there is an overhead of c. 9s for 1,000 chunks. If one million loops takes 11s, then a chunk of a thousand loops will take c. 11ms which is a lot smaller than needed to keep mIRC responsive. If we assume that to keep mIRC feeling responsive we need to process other activities (say) every 100ms, this suggests that we should be able to run 100 chunks of 10,000 iterations rather than 1,000 of 1,000, and by doing this reduce the overhead of chunking by a factor of 10, which should give us a run time of c. 11.7s - and when I tried it mIRC still felt pretty responsive e.g. to keystrokes, and it did indeed take c. 11.7s to run.  
  
 
'''Summary:''' In this simple example, by chunking in this way I was able to keep mIRC responsive during a loop which would normally lock-up mIRC for over 10s with an overhead of <10% - a definite win.
 
'''Summary:''' In this simple example, by chunking in this way I was able to keep mIRC responsive during a loop which would normally lock-up mIRC for over 10s with an overhead of <10% - a definite win.

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)