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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4a36b7df69d1af90 X-Google-Attributes: gid103376,public From: hugin777@my-deja.com Subject: Re: Announcing JGNAT public version 1.0p Date: 2000/04/07 Message-ID: <8ckscp$nv7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 607906419 References: <8bqd8g$sbs$1@nnrp1.deja.com> <8c2613$hce$1@nnrp1.deja.com> <8c7fh4$25g$1@nnrp1.deja.com> <8c92nl$nqn$1@nnrp1.deja.com> <8cak93$dtl$1@nnrp1.deja.com> <38EA152B.6D7A4481@earthlink.net> <1MNG4.630$n8.195854@news-east.usenetserver.com> <38ECB0CC.3B2941E2@earthlink.net> X-Http-Proxy: 1.0 x24.deja.com:80 (Squid/1.1.22) for client 212.242.3.50 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Fri Apr 07 14:46:53 2000 GMT X-MyDeja-Info: XMYDJUIDhugin777 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (Win95; U) Date: 2000-04-07T00:00:00+00:00 List-Id: In article <38ECB0CC.3B2941E2@earthlink.net>, Charles Hixson 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.