Article View: comp.lang.c
Article #22Re: Taming The Switch-Statement
From: bart
Date: Wed, 07 Oct 2026 10:49
Date: Wed, 07 Oct 2026 10:49
69 lines
4578 bytes
4578 bytes
On 07/10/2026 08:07, David Brown wrote:
> On 07/10/2026 02:25, bart wrote:
>> On 07/10/2026 00:14, Waldek Hebisch wrote:
>>> bart <bc@freeuk.com> wrote:
>>
>>>> What program can gcc compile in 10ms, Hello World?
>>>
>>> On my machine the following non-canonical version of Hello World:
>>>
>>> #include <unistd.h>
>>> int
>>> main(void) {
>>> write(1, "Hello\n", 6);
>>> return 0;
>>> }
>>>
>>> takes about 20-22 ms. More realistically, compilation of a lead
>>> C program (66 lines) and linking of several .o files (many
>>> produced by a non-C compiler) + libc needs 23 ms producing
>>> 66 kB executable (of which 20 kB is code and the rest is mainly
>>> debug info). The same, but linking statically to libc needs 56 ms
>>> and produces 550 kB executable (of which 413 kB is code).
>>> Note: the last two are for Risc-V. That is compiler runs on my PC,
>>> but executables only run on Risc-V machine. And actually
>>> transferring the executable takes more time than C compilation.
>>
>> So, on your machine, what's the throughput of gcc in lines per second?
>>
>> I mean something more accurate than the 300lps of your 6-line example
>> which will be mostly due to overheads.
>>
>> My compilers for Windows tend to work at up 0.5Mlps, and between 1-2
>> magnitudes faster than gcc.
>>
> I can't answer for other people, but when I write code, usually there is
> a fair amount of difference between different lines. The time taken for
> a compilation depends on the code!
>
> You can do all the speed measurements you like using files made from
> thousands of copies of the same pointless function. It means /nothing/.
I've given examples for real code.
But yes synthesised benchmarks can be used to spot bottlenecks. Maybe
other compiler developers can give it a go!
> "Lines per second" is a good way to rate machines for painting dashed
> lines down the middle of a road - not a way to judge a compiler.
>
> Your tools are useless to everyone except you. No one cares if they are
> a million times faster at being useless, people need tools that do
> something useful to them.
> So for the love of $DEITY, give it a break! You write plenty of
> interesting posts - your addiction to milliseconds is not part of that.
It is annoying though that no one wants to acknowledge that gcc IS slow.
I've given examples where you just want a compiler to do a mechanical
translation from source code to binary, just like you might translate
assembly to binary.
You DON'T CARE about detailed analysis. You might not even care about
the code quality for any number of reasons.
gcc does not give you an option where it is suddenly 10 or 20 times
faster (and it uses a fraction of the memory). We need -O-1 or -O-2.
Technical Details
Message-ID:
<11a583p$2pmng$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <119r8u3$34nce$1@dont-email.me> <119rau4$35ugq$1@dont-email.me> <119uo2c$3kc0t$1@paganini.bofh.team> <119uqnv$d6j2$1@dont-email.me> <20261005143559.157@kylheku.com> <11a1arj$1e8ks$1@dont-email.me> <11a295r$1lqal$3@dont-email.me> <11a2e2m$ef4o$2@dont-email.me> <11a2j83$1qu9n$1@dont-email.me> <11a2maf$1soc7$1@dont-email.me> <11a2vrn$20jj3$1@dont-email.me> <EI7xS.906$aNSb.21@fx20.iad> <11a37gv$23ruj$1@dont-email.me> <11a3vcj$88e7$1@paganini.bofh.team> <11a43hl$2e5k2$1@dont-email.me> <11a4r3i$2k7oa$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Taming The Switch-Statement Date: Wed, 7 Oct 2026 11:49:29 +0100 Organization: A noiseless patient Spider Lines: 69 Message-ID: <11a583p$2pmng$1@dont-email.me> References: <119qf6l$2rmg3$1@dont-email.me> <119r8u3$34nce$1@dont-email.me> <119rau4$35ugq$1@dont-email.me> <119uo2c$3kc0t$1@paganini.bofh.team> <119uqnv$d6j2$1@dont-email.me> <20261005143559.157@kylheku.com> <11a1arj$1e8ks$1@dont-email.me> <11a295r$1lqal$3@dont-email.me> <11a2e2m$ef4o$2@dont-email.me> <11a2j83$1qu9n$1@dont-email.me> <11a2maf$1soc7$1@dont-email.me> <11a2vrn$20jj3$1@dont-email.me> <EI7xS.906$aNSb.21@fx20.iad> <11a37gv$23ruj$1@dont-email.me> <11a3vcj$88e7$1@paganini.bofh.team> <11a43hl$2e5k2$1@dont-email.me> <11a4r3i$2k7oa$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 07 Oct 2026 10:49:29 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2939632"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18o94zEw4GhGcxkAW+aei9C"; posting-host="ddea08e9999a8df42a3f6de53c7cc773" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:uyiXbOJjkfIO4z9xRiqAYT+EbkA= sha256:ILSzKoBoIqniiQLojI1rf9RcnuxH4l1WGTgkkb4/+zA= sha1:QCiGVW1ze0vS3FCB5efFasTC6Gc= sha256:06aznjsDJK10/b2H3Leu1pwKIDpahwzAF1AQDD3DUzk= In-Reply-To: <11a4r3i$2k7oa$1@dont-email.me> Content-Language: en-GB