From: Johan Groth <jgroth@xpress.se>
Subject: Large strings in ADA
Date: 2000/04/16
Date: 2000-04-16T21:17:14+00:00 [thread overview]
Message-ID: <38FA3003.A38D7B51@xpress.se> (raw)
Hello,
I'm trying to write a program that converts a couple of types to strings
and are concatenated into one large string that is at the moment a
unbounded_string but when the string gets about 50KB big it takes longer
and longer to append to it.
The code looks like below. I need to concatenate about 2.5MB of data.
What is the fasted way to do that in ADA? Just for comparison a similar
program in C takes about one second.
Can anyone help me?
TIA,
Johan
procedure Main is
type String32 is
record
Info : String(1..32) := (others => ' ');
Len : Natural range 0 .. 32 := 0;
end record;
Str : String32;
No : Basic_Integer;
Flt : Basic_Float;
Msg : Unbounded_String := Null_Unbounded_String;
Last : Natural;
procedure Append_To_Msg (Str : in String;
Max_Len : in Natural;
Message : in out Asu.Unbounded_String;
Last : in out Natural) is
begin
Append(Message, " ");
Append(Message, Natural'Image(Max_Len));
Append(Message, " ");
Append(Message, Str);
Last := Asu.Length (Message);
end Add_To_Message;
begin
Str.info(1..6) := "hejsan";
Str.Len := 6;
No := 10;
Flt := 5.5;
for I in 1 .. 1600 loop
Append_To_Msg(Str.Info, Basic_Natural(Str.Len), Msg, Last);
if (I mod 100) = 0 then
Put(" " & Integer'Image(I));
end if;
end loop;
Put_Line("finished");
exception when Str:
others =>
Put_Line("exception in main: " & Ada.Exceptions.Exception_Name(Str));
end;
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Better to ask questions and seem stupid
than not to ask questions and remain stupid" -Unknown
Johan Groth <jgroth@xpress.se> Kupolen Data
next reply other threads:[~2000-04-16 0:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-16 0:00 Johan Groth [this message]
2000-04-16 0:00 ` Large strings in ADA David Starner
2000-04-17 0:00 ` Robert Dewar
2000-04-17 0:00 ` Florian Weimer
2000-04-17 0:00 ` Dale Stanbrough
2000-04-17 0:00 ` tmoran
2000-04-17 0:00 ` Johan Groth
2000-04-17 0:00 ` Robert Dewar
2000-04-17 0:00 ` David Starner
2000-04-17 0:00 ` Florian Weimer
2000-04-17 0:00 ` tmoran
2000-04-18 0:00 ` tmoran
2000-04-22 0:00 ` Johan Groth
2000-04-17 0:00 ` 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