bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Reduce function call overhead


From: arnold
Subject: Re: [bug-gawk] Reduce function call overhead
Date: Mon, 26 Nov 2018 04:36:03 -0700
User-agent: Heirloom mailx 12.4 7/29/08

I agree here. Inlining of function calls isn't going to happen in gawk.

In general in awk programs, I/O almost totally dominates computation
time.  If you are doing something that is by nature compute-intensive,
then you should probably look at using a different language.

Thanks,

Arnold

Wolfgang Laun <address@hidden> wrote:

> 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
> >
> >



reply via email to

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