help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Too fine design granularity leads to numerous macro/function/command


From: Emanuel Berg
Subject: Re: Too fine design granularity leads to numerous macro/function/command existed in Emacs.
Date: Sat, 14 Aug 2021 02:42:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hongyi Zhao wrote:

> It's not difficult for me or maybe some others, just too
> lazy to think for a while.

A lot of people like to think their lack of [whatever] is
because of laziness, however as for thinking of new reasons to
be lazy, the sure are hard at work. (I don't think that
applies to you but be careful with that word.)

> After all, we have so many
> convenient uinx tools and the excellent (but with
> performance penalty) pipe method at hand. Anyway, I've
> presented a comparison between pure AWK and UNIX toolchains
> as follows:
>
> $ time awk 'length > max_length { max_length = length; longest_line =
> $0 } END { print longest_line }' american-english-exhaustive
> correspond with someone about someone or something correspond with
> someone about someone or something

OK, great, so you got the one-liner to work, what did
you change?

> real    0m0.255s
> user    0m0.255s
> sys    0m0.003s
>
> $ time awk '{ print length($0) " " $0; }' american-english-exhaustive
> | sort -n | tail -1| cut -d ' ' -f2-
> correspond with someone about someone or something correspond with
> someone about someone or something
>
> real    0m1.794s
> user    0m1.853s
> sys    0m0.053s
>
> Obviously, the former is about 6 times faster than the latter.

Cool, try my command as well:

  $ awk '{ print length($0) " " $0; }' $file | sort -n | tail -1

The reason the piped commands are slower are because of the
context-switches so instead of time(1) try this command for
all three:

  $ perf stat sh -c 'COMMAND'

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]