From: hugin777@my-deja.com
Subject: Re: Announcing JGNAT public version 1.0p
Date: 2000/04/07
Date: 2000-04-07T00:00:00+00:00 [thread overview]
Message-ID: <8ckscp$nv7$1@nnrp1.deja.com> (raw)
In-Reply-To: 38ECB0CC.3B2941E2@earthlink.net
In article <38ECB0CC.3B2941E2@earthlink.net>,
Charles Hixson <charleshixsn@earthlink.net> wrote:
> [..] This will let me do the screen designs in Java, where there are
tools around
> and portable libraries that will (almost always) already be installed,
and the
> drive them with an Ada main program that calls the screens to get
information.
I wonder why you would do that ?
AFAICS the only reason could be low-level system interaction (which is
not portable:-).
The problem with Java is the amount of memory consumed by the JVM, not
the speed anymore (again AFAICS).
Try this in IBM's JDK 1.1.8:
public class Primes {
public static void main(String args[]) {
final int MAX_PRIME = Integer.parseInt(args[0]);
long start = System.currentTimeMillis();
boolean[] isPrime = new boolean[MAX_PRIME];
for (int i = 2; i < MAX_PRIME; i++) isPrime[i] = true;
for (int i = 2; i < MAX_PRIME; i++) {
if (isPrime[i]) markMultiplum(i, isPrime);
}
long end = System.currentTimeMillis();
for (int i = 2; i < MAX_PRIME; i++) {
if (isPrime[i]) System.out.print(i + ", ");
}
System.out.print("duration: " + ((end-start)/1000.) + "
seconds.");
}
// This better get inlined !!
// (Oh, well, the compiler won't read this, will it ? :-)
private static void markMultiplum(int divisor, boolean[] isPrime) {
for (int i = divisor+1; i < isPrime.length; i++) {
if (isPrime[i] && i % divisor == 0) isPrime[i] = false;
}
}
}
<-- cut
Note that "markMultiplum" actually get inlined by IBM's JIT !
Then try this in GNAT 3.12:
with Ada.text_io; use Ada.text_io;
with ada.command_Line; use ada.Command_Line;
with Ada.Calendar; use Ada.Calendar;
procedure Primes is
type BoolArray is array (Integer range <>) of Boolean;
--------
procedure MarkMultiplum (Divisor : in Integer;
Is_Prime : in out BoolArray) is
begin
for i in Divisor+1 .. Is_Prime'Last loop
if i mod Divisor = 0 then Is_Prime (i) := false; end if;
end loop;
end MarkMultiplum;
pragma Inline (MarkMultiplum);
--------
arg : String := Argument (1);
Max : Integer := Integer'Value (arg);
Is_Prime : BoolArray (2 .. Max) := (others => true);
start, finished : Time;
tm : Duration;
begin
start := Clock;
for n in Is_Prime'Range loop
if Is_Prime(n) then
MarkMultiplum (Divisor => n, Is_Prime => Is_Prime);
end if;
end loop;
finished := Clock;
tm := finished - start;
for I in Is_Prime'Range loop
if Is_Prime(i) then Put (i'Img & ","); end if;
end loop;
Put_Line (tm'Img & " seconds.");
end Primes;
<-- cut
On my machine (with gcc -O3) Java is 3 times faster !! (Due to Pentium
optimizations, I guess)
Neat 8-)
YMMV of course. These kind of "pseudo benchmarks" are of course not
worth much - but it gets my point through, anyway :-)
PS: I haven't tried JGNAT yet, unfortunately. But I hope the Java
version from the Ada source will be as fast as the one from the Java
source...
Regards,
Jens Jakob Jensen, Denmark.
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-04-07 0:00 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-28 0:00 Announcing JGNAT Professional version 1.0a Robert Dewar
2000-03-31 0:00 ` Announcing JGNAT public version 1.0p Robert Dewar
2000-04-01 0:00 ` John Merryweather Cooper
2000-04-02 0:00 ` Robert Dewar
2000-04-02 0:00 ` John Merryweather Cooper
2000-04-03 0:00 ` Robert Dewar
2000-04-02 0:00 ` John Merryweather Cooper
2000-04-03 0:00 ` Robert Dewar
2000-04-03 0:00 ` Robert Dewar
2000-04-04 0:00 ` JGNAT help puh-leeze G
2000-04-04 0:00 ` Geoff Bull
2000-04-06 0:00 ` G
2000-04-06 0:00 ` Geoff Bull
2000-04-04 0:00 ` Announcing JGNAT public version 1.0p Charles Hixson
2000-04-05 0:00 ` Geoff Bull
2000-04-05 0:00 ` David Botton
2000-04-06 0:00 ` Charles Hixson
2000-04-07 0:00 ` Geoff Bull
2000-04-07 0:00 ` hugin777 [this message]
2000-04-07 0:00 ` Pascal Obry
2000-04-07 0:00 ` Robert Dewar
2000-04-07 0:00 ` Ted Dennison
2000-04-08 0:00 ` Geoff Bull
2000-04-08 0:00 ` hugin777
2000-04-09 0:00 ` Optimizing flags Was: " Ken O. Burtch
2000-04-08 0:00 ` Geoff Bull
2000-04-08 0:00 ` Geoff Bull
2000-04-10 0:00 ` Pascal Obry
2000-04-10 0:00 ` hugin777
2000-04-10 0:00 ` Al Christians
2000-04-10 0:00 ` David Starner
2000-04-11 0:00 ` Brian Rogoff
2000-04-11 0:00 ` Tucker Taft
2000-04-11 0:00 ` Brian Rogoff
2000-04-11 0:00 ` David Starner
2000-04-11 0:00 ` Pascal Obry
2000-04-12 0:00 ` Pascal Obry
2000-04-04 0:00 ` ada_95
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox