comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Reading the while standard input into a String
Date: Mon, 6 Jun 2011 12:07:45 +0000 (UTC)
Date: 2011-06-06T12:07:45+00:00	[thread overview]
Message-ID: <slrniupgoh.i18.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 614f8acc-31c6-43e9-b304-c158584abc91@x3g2000yqj.googlegroups.com

Hello,

On 2011-06-06, Ludovic Brenta <ludovic@ludovic-brenta.org> wrote:
> Ludovic Brenta wrote on comp.lang.ada:
>> Natasha Kerensikova wrote on comp.lang.ada:
>>> However I thought that something similar to C's fread(), which can use
>>> efficient bulk memory copy, would be better than a loop of single
>>> character read (even when buffered in memory).
>>
>> How about:
>>
>> procedure Read_In_Chunks (Stream : in out
>> Ada.Streams.Root_Stream_Type'Class;
>>                           Result : out
>> Ada.Strings.Unbounded.Unbounded_String) is
> [...]
>
> I think I'm guilty of premature optimization.  I'd be curious to know
> whether Read_In_Chunks is actually faster than simply reading one
> character at a time and appending it to Result.  Only a benchmark
> could tell for sure.

The problem with benchmarks is that they are highly dependant on platform
and situation.

For what it's worth, I tried on my development system (Ubuntu Lucid),
using 1 KiB chunk size to read 10 MiB on random data, alternating calls
to each test program, 10 times each discarding the result (to warm up
caches) and then 10 times each gathering the results.

I got 100-160 ms spent in system mode for both, 90-110 ms in user mode
for your reader, and 440-490 ms in user mode for mine.

Using on-the-fly concatenation of 10 times the original 10 MiB file,
piped into the test programs, I get roughly the same ranges times ten.

So it looks like your optimization was justiified after all.



Thanks a lot for the idea,
Natasha



  reply	other threads:[~2011-06-06 12:07 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-05 16:20 Reading the while standard input into a String Natasha Kerensikova
2011-06-06  1:49 ` robin
2011-06-06  7:18 ` Dmitry A. Kazakov
2011-06-06 10:46   ` Natasha Kerensikova
2011-06-06 12:05     ` Dmitry A. Kazakov
2011-06-06 16:55       ` Jeffrey Carter
2011-06-06 17:42         ` Pascal Obry
2011-06-06 17:43         ` Pascal Obry
2011-06-06 18:31         ` Dmitry A. Kazakov
2011-06-06  8:09 ` stefan-lucks
2011-06-06  8:33 ` Ludovic Brenta
2011-06-06 10:08   ` Natasha Kerensikova
2011-06-06 10:27     ` Ludovic Brenta
2011-06-06 10:31       ` Ludovic Brenta
2011-06-06 12:07         ` Natasha Kerensikova [this message]
2011-06-06 15:18   ` Maciej Sobczak
2011-06-06 18:18     ` Dmitry A. Kazakov
2011-06-06 18:36       ` Maciej Sobczak
2011-06-06 18:53         ` Dmitry A. Kazakov
2011-06-06 19:10           ` J-P. Rosen
2011-06-06 19:46             ` Dmitry A. Kazakov
2011-06-06 23:37           ` Shark8
2011-06-07  3:00             ` Randy Brukardt
2011-06-07  7:25             ` Dmitry A. Kazakov
2011-06-07  7:32           ` Maciej Sobczak
2011-06-07  8:51             ` Dmitry A. Kazakov
2011-06-07  3:10         ` Randy Brukardt
2011-06-06 19:06       ` J-P. Rosen
2011-06-06 19:52         ` Dmitry A. Kazakov
2011-06-07  3:15         ` Randy Brukardt
2011-06-06 22:14   ` Robert A Duff
2011-06-06  9:46 ` Georg Bauhaus
2011-06-06 11:16 ` Georg Bauhaus
2011-06-06 12:11   ` Dmitry A. Kazakov
2011-06-06 13:32     ` Georg Bauhaus
2011-06-06 14:06       ` Dmitry A. Kazakov
2011-06-06 14:14         ` Georg Bauhaus
2011-06-07  3:19         ` Randy Brukardt
2011-06-06 18:14 ` John B. Matthews
2011-06-07 10:23   ` Martin
2011-06-07 16:57     ` John B. Matthews
2011-06-07 17:22     ` Robert A Duff
2011-06-07 17:55       ` John B. Matthews
2011-06-08  0:26         ` Robert A Duff
2011-06-08  7:38         ` Egil Høvik
2011-06-08  9:27           ` Martin
2011-06-08 12:04             ` Egil Høvik
2011-06-08 18:09               ` Niklas Holsti
2011-06-09  0:46                 ` Randy Brukardt
2011-06-10  8:22                   ` Martin
replies disabled

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