NO

Author Topic: Performance of the runtime-library of Pelles C  (Read 4189 times)

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Performance of the runtime-library of Pelles C
« on: January 31, 2008, 09:10:05 AM »
I found in an other lcc-forum a code example which calculates Roman numbers. I tried it with Pelles C and it worked perfect. Then i had the idea to take the time for the calculation and found that the program compiled with Pelles C tooks 10 times more time to calculate then the program compiled with the other lcc-compiler. I was surprised, because normally programs produced with Pelles C are faster.

So I tested the speed with other compilers and found that Pelles C was one of slowest.

That I had the idea to link the Pelles C program with msvcrt.lib - and it was again one of the fastest programs.

So I have the question: Why is the output to stdout with the Pelles C runtime so slow?
« Last Edit: January 31, 2008, 09:25:29 AM by AlexN »
best regards
 Alex ;)

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Performance of the runtime-library of Pelles C
« Reply #1 on: January 31, 2008, 12:10:14 PM »
Not that I think the output to stdout is much to time, but have you tried your program with v5.0 (beta)? Previous version(s) kept creating a new output handle while this version will cache a previously allocated handle... Maybe faster. Otherwise, can you post the actual code and explain how you timed it?

EDIT: mostly a matter of buffering, though. Add the following line before the program starts using stdout, and it will be much faster.

Code: [Select]
setvbuf(stdout, NULL, _IOFBF, 4096);  /* 4096 is just an example */
« Last Edit: January 31, 2008, 02:56:12 PM by Pelle »
/Pelle

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: Performance of the runtime-library of Pelles C
« Reply #2 on: February 01, 2008, 08:23:50 AM »
Not that I think the output to stdout is much to time, but have you tried your program with v5.0 (beta)?
You are right, I used for this test your new v5.0 beta

Previous version(s) kept creating a new output handle while this version will cache a previously allocated handle... Maybe faster. Otherwise, can you post the actual code and explain how you timed it?
The program writes a table of Arabic and Roman numbers from 1 to 5000 (but I don't think, that the contant of the output is relevant). There is an output with about 10 to 40 chars and 5000 lines). I timed it with an program which starts another program and measure its complete runtime.
I tried it with a normal run, a run where the output was transfered to afile and a run where the output was transfer to nul.

EDIT: mostly a matter of buffering, though. Add the following line before the program starts using stdout, and it will be much faster.
I added your code and got a remarkable reduction of the runtime.

normal run:
Pelles C: ~4,0 sec -> ~1,4 sec (other lcc compiler ~2,8 sec)

run with output toa file:
Pelles C: ~0,9 sec -> ~0,14 sec (other lcc compiler ~0,15 sec)

run with output to 0:
Pelles C: ~0,9 sec -> ~0,03 sec (other lcc compiler ~0,08 sec)

I know that my measuring of the time is not very exact but it show a line.  :)
best regards
 Alex ;)

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Performance of the runtime-library of Pelles C
« Reply #3 on: February 01, 2008, 09:55:42 PM »
stdin/stdout/stderr is mainly for interaction with the user, and the user will be the delaying factor. By default I choose a conservative approach that should always work - with the least amount of fuzz. Changing the buffering strategy may often increse the speed, but may also cause problems for some programs, hence the conservative approach. In my opinion this is a typical non-problem.
/Pelle