From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e169af38f0a27bda X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-23 14:00:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: When shoul Pragma Inline be used? Date: 23 Feb 2003 17:00:51 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <3E590DC1.5000005@acm.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1046037651 1984 199.172.62.241 (23 Feb 2003 22:00:51 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 23 Feb 2003 22:00:51 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:34491 Date: 2003-02-23T17:00:51-05:00 List-Id: Jeffrey Carter writes: > A general rule I learned is: Inline small subprograms if your program > has tight time constraints. "Small" is not precisely defined; you have > to decide how many statements is too many. Some compilers will > automatically inline calls to small subprograms. Such compilers must > have a precise definition of "small", probably based on the size of the > object code. I think such compilers usually measure the size of some low-level intermediate code, rather than the object code itself. It amounts to more-or-less the same thing. But note that in some cases the size of the object code can change dramatically due to inlining. For example: function F(X: Some_Enum_Type) return Integer is begin case X is when Red => return 17; when Green => ... when ... ... -- 100 more lines of code end case; end F; While F is probably too big for inlining just looking at the amount of code in the body of F, a call like "F(Red)", if inlined, will boil down to just the literal number "17" (assuming the optimizer is smart enough). The advice given elsewhere in this thread, to measure the speed-effects of pragma Inline, is good. If your compiler doesn't inline automatically, guess where to put pragmas Inline (based on size of code and other issues), and measure the effect. - Bob