Re: macro for fir list?

Liste des GroupesRevenir à l c 
Sujet : Re: macro for fir list?
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.c
Date : 30. Mar 2024, 16:24:48
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <uu97bc$3hkg4$1@i2pn2.org>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
bart wrote:
On 30/03/2024 09:56, fir wrote:
>
>
yet other example
>
//bytes container
   char* bytes = NULL; int bytes_size = 0;
   void bytes_add(char val) {
(bytes=(char*)realloc(bytes,++bytes_size*sizeof(char)))[bytes_size-1]=val;
 }
   void bytes_load(char* name)  {    FILE *f = fopen(name, "rb"); int
c; while((c=getc(f))!=EOF) bytes_add(c);   fclose(f);  }
>
This is pretty inefficient. Loading an 8MB file this way takes 3
seconds, vs. 50ms to load it in one go.
>
Loading the same 90KB file 10,000 times took 120 seconds, vs. 0.8
seconds even using a scripting language.
>
80% of the inefficiency is growing the buffer one byte at a time. The
other 20% is reading the file one byte at a time.
>
>
according to what its said its a fault of reallock designers imo
(unles maybe there is faster reallock to use) as it could be
much faster imo
i vaguelly remember some code of mmclean when he uset fgets it
was pointed out its slow - but i dont remember if it was
ponted reallock is yet 3 times slower than fgets if your measurings are right and representative

Date Sujet#  Auteur
28 Mar 24 * macro for fir list?20fir
28 Mar 24 +* Re: macro for fir list?4fir
28 Mar 24 i`* Re: macro for fir list?3fir
28 Mar 24 i `* Re: macro for fir list?2fir
29 Mar 24 i  `- Re: macro for fir list?1fir
30 Mar 24 `* Re: macro for fir list?15Opus
30 Mar 24  `* Re: macro for fir list?14fir
30 Mar 24   +- Re: macro for fir list?1fir
30 Mar 24   `* Re: macro for fir list?12fir
30 Mar 24    `* Re: macro for fir list?11fir
30 Mar 24     +* Re: macro for fir list?9fir
30 Mar 24     i`* Re: macro for fir list?8bart
30 Mar 24     i +* Re: macro for fir list?6fir
30 Mar 24     i i`* Re: macro for fir list?5fir
30 Mar 24     i i `* Re: macro for fir list?4fir
30 Mar 24     i i  +- Re: macro for fir list?1fir
30 Mar 24     i i  +- Re: macro for fir list?1fir
30 Mar 24     i i  `- Re: macro for fir list?1fir
30 Mar 24     i `- Re: macro for fir list?1fir
30 Mar 24     `- Re: macro for fir list?1fir

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal