Sujet : Re: xxd -i vs DIY Was: C23 thoughts and opinions
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 29. May 2024, 01:54:23
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v35qrg$qhnf$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla Thunderbird
On 28/05/2024 21:23, Michael S wrote:
On Tue, 28 May 2024 19:57:38 +0100
OK, I had go with your program. I used a random data file of exactly
100M bytes.
>
Runtimes varied from 4.1 to 5 seconds depending on compiler. The
fastest time was with gcc -O3.
>
It sounds like your mass storage device is much slower than aging SSD
on my test machine and ALOT slower than SSD of David Brown.
David Brown's machines are always faster than anyone else's.
Your machine showed 1.3 seconds for 50MB, or 2.6 seconds for 100MB.
Unchanged, the fastest on my machine was 4.1 seconds for 100MB.
I've since tweaked your program to isolate the reading and writing parts, also to make it load the whole file in one fread call, so that I can compare overall times better.
One more thing I did was to write to a specific named file, not to stdout.
Overall, gcc-O2/O3 (they're the same) now has a best timing of 1.9 seconds. My language's version with my compiler has a best timing of 2.0 seconds.
(Unoptimised gcc, mcc, tcc give timings of around 2.7 seconds.
DMC (and old 32-bit compiler) is unoptimised, and 1.5 optimised.
lccwin32 takes over 5 seconds in either case.)
I suspect that your system just has a much faster fgetc implementation. How long does an fgetc() loop over a 100MB input take on your machine?
On mine it's about 2 seconds on Windows, and 3.7 seconds on WSL. Using DMC, it's 0.65 seconds.