[fpc-pascal] Underscores in numerical literals - grouping
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Nov 22 15:29:51 CET 2016
On Tue, 22 Nov 2016 13:32:03 +0000
Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:
> On 2016-11-22 13:26, Sven Barth wrote:
> > I think the difference a tab versus a couple of spaces makes (even if
> > across a whole file or a whole project) will be insignificant
>
> Well, for every byte in the file, the parser needs to figure out what to
> do with it. Less bytes, means less processing cycles - no matter how
> small. They do add up in the end when you have to parse some 1 million
> lines of code.
>
> But there was also a reason I put a smiley face at the end of my post.
> [technically what I said is sound and true, but I have no metrics to
> prove it]
You forgot to consider how scanners work, i.e. how they check and
skip spaces.
Here are some numbers:
Compiling Lazarus sources 'make clean all' 1249309 lines 3 times
0m51.682s
0m51.415s
0m51.698s
Lazarus uses indentation of 2, so replacing each double space with one
tab saves 3.7mb. Compiling 3 times:
0m52.003s
0m51.294s
0m51.452s
This is a desktop system, so there is always a bit of noise. As you can
see, the time difference is not measurable.
To estimate the potential speed up:
Replacing all multi spaces with one space saves 6.1mb. Compiling 3
times:
0m51.064s
0m50.733s
0m51.120s
It seems scanning the spaces costs about 1%.
My conclusion: That tabs costs less cpu time in Pascal code is a myth.
Mattias
More information about the fpc-pascal
mailing list