1. Load time trimming
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Jul 20, 1997
- 629 views
Two questions for Euphoria gurus: 1) Suppose you are writing an app. that involves using pieces of many different include files, but *only* pieces of those include files. That is, one function out of this one, another from that one, etc. Do you think/know if the load time could be reduced by making alternate copies of those include files which contained only the relevent functions (and whatever support functions they in turn need)? Or does Euphoria already have some method built in to trim the fat? That last mentioned seems unlikely to me, since Euphoria has to load the function before it can see if it is used or not (although I suppose it might throw out unused code once it has it all in memory, that wouldn't help load time any; it might even lengthen it). I realize that Euphoria loads pretty fast anyway, so this is really just a concept question. 2) Does anyone know of a way to emulate a case statement in Euphoria other than an elsif chain? The case statements I'm referring to are like Qbasic's Select Case, or C's switch(). Nothing wrong with elsif chains, I'm just curious if it can be done. Craig
2. Re: Load time trimming
- Posted by Robert Craig <rds at MSN.COM> Jul 22, 1997
- 628 views
Craig Gilbert writes: > 1) Suppose you are writing an app. that involves using pieces of many > different include files, but *only* pieces of those include files. That is, > one function out of this one, another from that one, etc. Euphoria does not do any special optimization here. It will load the unneeded functions and will not try to reclaim their allocated memory later. A perfectionist could try to pick and choose precisely the set of routines that he needs. This would save him a few milliseconds of load time and a few K of memory. > 2) Does anyone know of a way to emulate a case statement in Euphoria other > than an elsif chain? The case statements I'm referring to are like Qbasic's > Select Case, or C's switch(). > Nothing wrong with elsif chains, I'm just curious if it can be done. In the interests of simplicity, a case statement was never added to Euphoria. elsif chains are used instead. In some situations a case statement might be more readable, and possibly more efficient. I have some ideas for optimizing certain elsif-chains to match the efficiency of case statements, but I've never seen a Euphoria program where the linear series of comparisons implied by elsif was slowing the program down very much. (With case statements you can often set up a fast n-way branch, by indexing into a jump table.) If you *are* being slowed down, run "with profile", and reorder your elsifs to put the most common cases first. You can also set up a kind of binary search for the matching case, using nested if statements, rather than just doing a linear series of elsif's. There are hundreds of language features that are completely justifiable when viewed in isolation, but if you implement all of them you create a mess (like C++). Regards, Rob Craig Rapid Deployment Software