bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] math functions


From: Peng Yu
Subject: Re: [bug-gawk] math functions
Date: Fri, 14 Dec 2018 11:33:17 -0600

> The best way is to write a loadable extension to make more functions
> available. It's not hard, see the documentation, which is online at
> https://www.gnu.org/software/gawk/manual/html_node/Dynamic-Extensions.html.
>
> If you don't know how to program in C, we can discuss my consulting rates,
> off-list.

http://www.drdobbs.com/shell-corner-bash-dynamically-loadable-b/199102950

Bash also has a loadable extension that can be used to load a dynamic
library. I think that it should be able to make gawk as a bash
loadable to reduce the startup time of gawk. See below---gawk startup
time is much slower than a bash function or a bash built-in command.

Will it cause any problem to make gawk a bash loadable module (e.g.,
could it conflict with the extension loading facility in gawk)?
Thanks.

$ cat ./main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
function f {
    :
}
TIMEFORMAT=%R
time for ((i=0;i<100;++i))
do
    f
done
time for ((i=0;i<100;++i))
do
    echo -n
done
time for ((i=0;i<100;++i))
do
    awk -e 'BEGIN {}'
done
$ ./main.sh
function f {
    :
}
TIMEFORMAT=%R
time for ((i=0;i<100;++i))
do
    f
done
0.003
time for ((i=0;i<100;++i))
do
    echo -n
done
0.002
time for ((i=0;i<100;++i))
do
    awk -e 'BEGIN {}'
done
0.938

-- 
Regards,
Peng



reply via email to

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