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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c3a1871d2161925 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-03 09:36:46 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!wanadoo.fr!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: C/Ada performance comparison Date: Tue, 3 Jul 2001 12:20:53 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9hsrd6$aag$1@nh.pace.co.uk> References: <3B3C8E6A.39361C75@labe.felk.cvut.cz> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 994177254 10576 136.170.200.133 (3 Jul 2001 16:20:54 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 3 Jul 2001 16:20:54 GMT 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:9384 Date: 2001-07-03T16:20:54+00:00 List-Id: There shouldn't be any inherent reasons why Ada code should run slower than C code, but there are lots of problems with comparisons and conversions. You didn't say what compiler was used for the C program, and this can make a big difference in performance. Just mechanically translating C code to Ada may not always give you the best results. Sometimes this leads to misuse of Ada constructs. You'll want to try to identify the specific features of the program are consuming all of the CPU and then re-ask the question. If you have some trace/timing tools to figure this out, it would help. Ada provides a lot of runtime checking that C does not - this can lead to a large slowdown. If the program is working, you may want to eliminate the runtime checking and see if the performance takes a big jump. Look at "Pragma Supress" in the ARM and/or your compiler documentation for appropriate switches to shut off various checks. If your Ada program has no tasks, it should not (in theory) impose any task overhead. However, implementations vary. I don't know the answer to this one, but you may discover a lot if you can do a little bit of timing study. I'd suggest that you *first* supress all checks and see what that does to your performance. It is easy to accomplish and may cure most of your ills. Second, you might want to start throwing in different layers of optimization - look at the compiler doc for switch values & try some out. If that doesn't bring the time down significantly, I'd do some timing checks on major chunks of the code that you think might be consuming the bulk of the time. If you don't have an analyzer, you can always use Ada.Calendar features - provided your clock gives you sufficient granularity and you're not checking at too low a level. Print some start times and stop times & maybe you'll find something interesting. Repost here with code sections you think are running unusually slow & maybe we can help you figure out what is wrong. On my web page at: http://www.mcondic.com/ and follow the links to: http://www.mcondic.com/Ada_Programming.html You'll find a section labeled "Utilities". Look in the code (at: http://www.mcondic.com/util_v3a.txt if you can't find the link) for a package called: UTIL.Stopwatch - this may be useful in trying to clock events within your code. Hope this helps. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "Tomas Hlavaty" wrote in message news:3B3C8E6A.39361C75@labe.felk.cvut.cz... > Hi, > > I have a question about the CPU load of Ada programs. I have a program > reimplemented from C to Ada (Linux, GNAT) and now I've found the Ada > program consumes about 7 times more CPU time than the C one. Is it > common case or does it indicate an error in my Ada implementation (I'm > quite new in Ada)? Is there any comparison/statistics on performance of > C/Ada programs? > > I've tried to reduce the CPU time load of the Ada program and I found > some surprising results. I compared rts-fsu and rts-native runtime > environment and I found that rts-fsu is better (lower CPU load and only > one running process per running program compared to rts-native). Why? I > thougth rts-native should be better because it is more oriented towards > the OS (gthreads...). Why is there so many processes when executing > program compiled with rts-native? The Ada program has no tasks. > > And the last question: Is there any standard/common way how to implement > synchronous I/O multiplexing like in C (select)? > > Thank you, > > Tomas > > -- > Tomas Hlavaty mailto:hlavaty@labe.felk.cvut.cz > Department of Cybernetics http://labe.felk.cvut.cz/~hlavaty > Faculty of Electrical Engineering phone: (+420 2) 2435 7284 > Czech Technical University