Liste des Groupes | Revenir à cl c |
On Tue, 28 May 2024 19:57:38 +0100
bart <bc@freeuk.com> wrote:
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 SSDMy machine uses an SSD.
on my test machine and ALOT slower than SSD of David Brown.
The difference in file sizes for N bytes will be a factor of 2:1 maximum (all "1," or all "123," for example).I then tried a simple program in my language, which took 10 seconds.Yes, I try to get line length almost fixed (77 to 80 characters) and
>
I looked more closely at yours, and saw you used a clever method of a
table of precalculated stringified numbers.
>
Using a similar table, plus more direct string handling, the fastest
timing on mine was 3.1 seconds, with 21 numbers per line. (The 21 was
supposed to match your layout, but that turned out to be variable.)
>
make no attempts to control number of entries per line.
Since you used random generator, a density advantage of my approach is
smaller than in more typical situations, where 2-digit numbers are more
common than 3-digit numbers.
Also, I think that random numbers are close to worst case for branch
predictor / loop length predictor in my inner loop.
Were I thinking about random case upfront, I'd code an inner loop
differently. I'd always copy 4 octets (comma would be stored in the same
table). After that I would update outptr by length taken from
additional table, similarly, but not identically to your method below.
There exist files that have near-random distribution, e.g. anything
zipped or anything encrypted, but I would think that we rarely want
them embedded.
This hardcodes the input filename. 'readfile' is a function in my
library.
>
--------------------------------
>
[0:256]ichar numtable
[0:256]int numlengths
>
proc main=
ref byte data
[256]char str
const perline=21
int m, n, slen
byte bb
ichar s, p
>
for i in 0..255 do
numtable[i] := strdup(strint(i))
numlengths[i] := strlen(numtable[i])
od
>
data := readfile("/c/data100")
Reading whole file upfront is undoubtly faster than interleaving ofWhy not? Isn't the whole point to have a practical tool which is faster than xxd?
reads and writes. But by my set of unwritten rules that I imposed on
myself, it is cheating.
Les messages affichés proviennent d'usenet.