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,22d1652a85f14a1e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-27 15:17:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.airnews.net!cabal12.airnews.net!usenet From: "John R. Strohm" Newsgroups: comp.lang.ada Subject: Re: Speeding up Ada procedure? Date: Thu, 27 Feb 2003 16:55:51 -0600 Organization: Airnews.net! at Internet America Message-ID: <39C63F6EB5F4631F.090DB39F2787B505.06BDC350E9BE2563@lp.airnews.net> X-Orig-Message-ID: References: <1d13e1b4.0302261526.40058154@posting.google.com> Abuse-Reports-To: abuse at airmail.net to report improper postings NNTP-Proxy-Relay: library1-aux.airnews.net NNTP-Posting-Time: Thu Feb 27 17:14:52 2003 NNTP-Posting-Host: !_*291k-X-L2`5Q (Encoded at Airnews!) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:34692 Date: 2003-02-27T16:55:51-06:00 List-Id: "Papandopulo" wrote in message news:1d13e1b4.0302261526.40058154@posting.google.com... > I have certain procedures dealing with > large arrays which are potential performance > bottlenecks. While they didn't cause > performance problems yet I intuitively > feel they will. George, there is a very fundamental rule-of-thumb in this racket. You NEVER speculate about things that MIGHT become performance problems. You profile the code and FIND OUT if they are IN FACT performance problems. Some years ago, on a 50 MHz 486, I had a bunch of floating-point calculations. I was PLANNING on rewriting them in fixed-point (integer), for speed, because I was worried that they might be a problem. Before I did that, however, I ran them and measured the time they took. When I discovered that they were nowhere near as bad as I'd expected them to be, I left them in floating-point. End of problem. > Is it a way to remove runtime array > bounds and other checks for particular > procedure ? pragma suppress > While Ada checks are excellent on > control-type part of program where is > a lot of logic and not much time spent > it can become deadly if massive arrays > of data are being processed. > > If the procedure just takes an array and > produces an array I can be sure it's not > faulty by testing it with different size > arrays and than turning off runtime checks. No, you can't, not necessarily. You have to understand the algorithm, and be able to say that the subscript expressions will never blow. Some Ada compilers are smart enough to figure out that subscript expressions will always be in bounds, and optimize out the checks. The other thing is this: Depending on what you are doing, do you MIND if the code runs slowly? If you're not doing real-time stuff, it may not be an issue. Are the consequences of an UNDETECTED subscript fault worse than having the code run slowly? What about the consequences of a program crash? (Twenty years ago, I watched a one-byte error in some 8080 code scrag the hard disk on an Intel MDS. I was writing a threaded-code interpreter, playing games with the stack pointer. It wasn't pretty. After the hardware guy rebuilt the disk, I formed a habit of hitting the write-protect switches before I started my code.)