stdio performance in tango, stdlib, and perl
Sean Kelly
sean at f4.ca
Sat Mar 24 07:59:55 PDT 2007
torhu wrote:
> torhu wrote:
>> ---
>> /* C test w/malloc and free */
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> int main() {
>>
>> char *buf = malloc(1000);
>> while (fgets(buf, sizeof(buf), stdin)) {
>> fputs(buf, stdout);
>> free(buf);
>> buf = malloc(1000);
>> }
>> free(buf);
>> return 0;
>> ---
>
> Whoops, can anyone spot the bug? When I fixed it, the time it took to
> run my test went down from about 23 to about 3 seconds.
The fgets(sizeof(buf)) looks like it could affect read performance a tad :-)
Sean
More information about the Digitalmars-d
mailing list