lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Reading an empty file into a string


From: Greg Chicares
Subject: Re: [lmi] Reading an empty file into a string
Date: Sun, 21 Sep 2008 18:47:23 +0000
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

On 2008-09-21 16:26Z, Vadim Zeitlin wrote:
> 
>  Otherwise replacing the in_avail() check with "is.rdbuf()->sgetc() !=
> Traits::eof()" should work too: sgetc() will result in an attempt to read
> from the file and if it fails for any reason other than the file being
> empty, it should set the failbit or badbit. IOW I propose the following
> patch:

I'll integrate that soon, as well as your other patch. I had just
finished an update of my own, so I committed that to get it out
of the way, but I'll merge yours, too. Thanks--I thought it'd be
good to add a C benchmark, and I was trying to remember how to do
file IO in C. It's been so long that I would have forgotten BUFSIZ
or whatever it is.

>  FWIW here is the result under Linux with g++ 4.1.2:
> 
>   Method 0: 2.758e-03 s =    2757620 ns, mean of 100 iterations
>   Method 1: 3.529e-05 s =      35289 ns, mean of 284 iterations
> 
> I'm not quite sure if everything is correct here (why 284 iterations for
> the second method?)

That's because of my 20080915T1414Z change:
  "Improve timing accuracy for operations that take very little time."
I wanted to time something in 'expression_template_0_test.cpp'
that was so fast that one hundred iterations took almost no time,
so successive timings varied a great deal. To increase stability,
I changed the timing algorithm so that it never spends less than
one percent of the maximum time allowed, even if the iteration
counter has reached one hundred.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]