From: dvdeug@my-deja.com
Subject: Optimization Question
Date: Mon, 22 Jan 2001 00:05:21 GMT
Date: 2001-01-22T00:05:21+00:00 [thread overview]
Message-ID: <94ftfu$b59$1@nnrp1.deja.com> (raw)
I'm trying to write a program similar to the Unix utility strings, as my
copy of strings refuses to run a 17GB file. It seems to work, but it's
about 10x slower than strings, and rough calculations puts running time
on that 17GB file at 10 hours. I'm running the woody Debian version of
GNAT (3.13) on i686-linux-gnu, and I compiled the program with gnatmake
-g -gnatwa -gnatpn -Wall -W -O3 strings.adb. Is there anything I've
missed that speed this program a lot? (It's been run through gcov, so
the numbers up front are execution counts.)
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Sequential_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO;
2 procedure Strings is
1 type Byte is mod 2 ** 8;
package Byte_IO is new Ada.Sequential_IO (Byte);
use Byte_IO;
56710 function String_Charp (A : Character) return Boolean
is
begin
56710 return Is_ISO_646 (A) and then
(Is_Graphic (A) or else A = HT or else A = LF or else A = CR);
end String_Charp;
pragma Inline (String_Charp);
1 Binary_File : File_Type;
1 Letter_Buffer : String (1 .. 4);
subtype Buffer_Size is Integer range 0 .. 4;
1 Letters_Found : Buffer_Size := 0;
1 Current_Char : Byte;
1 Seperating_String : constant String := (LF, NUL);
begin
1 if Argument_Count /= 1 then
###### Set_Exit_Status (1);
###### Ada.Text_IO.Put ("One file name only!");
###### return;
end if;
1 Open (Binary_File, In_File, Argument(1));
56711 loop
56711 Read (Binary_File, Current_Char);
56710 if String_Charp (Character'Val (Current_Char))
then
29610 if Letters_Found < 4 then
8453 Letters_Found := Letters_Found + 1;
8453 Letter_Buffer (Letters_Found) :=
Character'Val (Current_Char);
8453 if Letters_Found = 4 then
916 Ada.Text_IO.Put (Letter_Buffer);
end if;
else
21157 Ada.Text_IO.Put (Character'Val
(Current_Char));
end if;
else
27100 if Letters_Found = 4 then
916 Ada.Text_IO.Put (Seperating_String);
end if;
27100 Letters_Found := 0;
end if;
end loop;
###### Ada.Text_IO.Put ("Invalid end!");
###### Set_Exit_Status (2);
exception
1 when End_Error =>
1 Close (Binary_File);
###### when others =>
###### raise;
end Strings;
--
David Starner - dstarner98@aasaa.ofe.org
Sent via Deja.com
http://www.deja.com/
next reply other threads:[~2001-01-22 0:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-22 0:05 dvdeug [this message]
2001-01-22 1:57 ` Optimization Question Robert Dewar
2001-01-22 3:22 ` dvdeug
2001-01-22 4:05 ` Robert Dewar
2001-01-22 4:06 ` Robert Dewar
2001-01-22 19:04 ` M. Kotiaho
2001-01-22 20:22 ` dvdeug
2001-01-22 15:24 ` Ted Dennison
2001-01-22 16:12 ` Robert Dewar
2001-01-22 16:48 ` Ted Dennison
2001-01-22 16:15 ` Robert Dewar
2001-01-22 15:26 ` Ted Dennison
2001-01-22 16:17 ` Robert Dewar
2001-01-22 16:59 ` Ted Dennison
2001-01-22 22:01 ` Keith Thompson
2001-01-22 22:52 ` dvdeug
2001-01-23 6:46 ` Keith Thompson
[not found] ` <94ld65$1hs$1@nnrp1.deja.com>
[not found] ` <864ryodb1q.fsf@acm.org>
[not found] ` <3A6F663E.C84B94D8@acm.org>
2001-01-26 16:30 ` Optimization Question -- Follow up on using the stream read (and write) procedures directly Jeff Creem
2001-01-26 21:46 ` Florian Weimer
2001-01-27 19:14 ` Jeff Creem
2001-01-28 0:26 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox