[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Reduce function call overhead
From: |
Wolfgang Laun |
Subject: |
Re: [bug-gawk] Reduce function call overhead |
Date: |
Mon, 26 Nov 2018 11:40:58 +0100 |
No. - If you begin to worry about 25 nanoseconds per call you need to use a
more efficient language like C or Java.
-W
On Mon, 26 Nov 2018 at 11:15, Peng Yu <address@hidden> wrote:
> Hi,
>
> The following code shows the performance overhead of a function call.
> Is there a way to improve the performance of function call (e.g.,
> inline functions)? Thanks.
>
> $ time awk 'BEGIN { $1="a"; for(i=0;i<100000000;++i) {} }'
>
> real 0m3.998s
> user 0m3.890s
> sys 0m0.027s
> $ time awk 'BEGIN { $1="a"; for(i=0;i<100000000;++i) x=$1 }'
>
> real 0m6.264s
> user 0m6.086s
> sys 0m0.047s
> $ time awk 'function f() { return $1 } BEGIN { $1="a";
> for(i=0;i<100000000;++i) x=f() }'
>
> real 0m8.819s
> user 0m8.583s
> sys 0m0.059s
>
> --
> Regards,
> Peng
>
>