comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: C/Ada performance comparison
Date: Tue, 3 Jul 2001 12:20:53 -0400
Date: 2001-07-03T16:20:54+00:00	[thread overview]
Message-ID: <9hsrd6$aag$1@nh.pace.co.uk> (raw)
In-Reply-To: 3B3C8E6A.39361C75@labe.felk.cvut.cz

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" <hlavaty@labe.felk.cvut.cz> 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





  reply	other threads:[~2001-07-03 16:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-29 14:19 C/Ada performance comparison Tomas Hlavaty
2001-07-03 16:20 ` Marin David Condic [this message]
2001-07-03 19:09 ` tmoran
2001-07-03 22:09 ` Jeffrey Carter
2001-07-04 17:27   ` Colin Paul Gloster
2001-07-04 17:43     ` Samuel Tardieu
2001-07-05  7:12       ` Colin Paul Gloster
2001-07-05 11:55         ` Larry Kilgallen
2001-07-05 21:46         ` Robert Dewar
2001-07-05 13:37   ` Marin David Condic
2001-07-05 14:49     ` Jean-Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox