bug-gawk
[Top][All Lists]
Advanced

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

Re: Compiled version of awk program


From: Peng Yu
Subject: Re: Compiled version of awk program
Date: Wed, 30 Jun 2021 19:30:42 -0500

How to use it? I got something like this. But I don't find libawka.h
in the package.

$ ./awka 'BEGIN { print "xxx"}'
/* This file generated by AWKA */

#include <libawka.h>
#include <setjmp.h>

static jmp_buf context;

static a_VAR **_lvar;
static a_VAR *_lits0_awka=NULL;
static void BEGIN();

static void
BEGIN()
{
  awka_print(NULL, 0, 0, awka_arg1(a_TEMP, _lits0_awka));
  awka_exit(0);

}



int
main(int argc, char *argv[])
{
  awka_config_max_base_gc(2);
  awka_config_max_fn_gc(2);

  awka_split_req(0); awka_split_max(INT_MAX);


  awka_varinit(_lits0_awka); awka_strncpy(_lits0_awka, "xxx", 3);

  if (!_lvar) {
    malloc( &_lvar, 2 * sizeof(a_VAR *) );
    _lvar[0] = _lits0_awka;
    _lvar[1] = NULL;
  }

  awka_register_gvar(0, NULL, NULL);
  awka_register_fn(0, NULL, NULL);
  awka_init(argc, argv, "0.7.6", "Mar 25, 2021");

  awka_dol0_only(1);

  BEGIN();

  free(_lits0_awka->ptr); free(_lits0_awka);

  awka_exit(0);
}

On 6/30/21, pjfarley3@earthlink.net <pjfarley3@earthlink.net> wrote:
> http://awka.sourceforge.net/index.html
>
> Also a github fork and enhanced version of Awka:
>
> https://github.com/noyesno/awka
>
> HTH
>
> Peter
>
>> -----Original Message-----
>> From: bug-gawk <bug-gawk-bounces+pjfarley3=earthlink.net@gnu.org> On
>> Behalf Of Peng Yu
>> Sent: Wednesday, June 30, 2021 8:07 AM
>> To: Wolfgang Laun <wolfgang.laun@gmail.com>
>> Cc: bug-gawk <bug-gawk@gnu.org>
>> Subject: Re: Compiled version of awk program
>>
>> On Wed, Jun 30, 2021 at 5:20 AM Wolfgang Laun <wolfgang.laun@gmail.com>
>> wrote:
>>
>> > What factor would you consider as sufficient for a speed improvement?
>> >
>>
>> Any improvement is acceptable as long as the improvement is automatic,
>> although the faster the better.
>>
>> On what do you base your surmise that a translation to C will improve the
>> > overall speed of this awk program by this factor?
>> >
>>
>> Cut is much faster than an equivalent awk program.
>>
>> What makes you certain that there is no algorithm that can be improved?
>> >
>>
>> This is not relevant question. I am asking for a free improvement. Any
>> changes
>> to the algorithm would not be automatically done.
>>
>> >
>> > -W
>> >
>> >
>> > On Wed, 30 Jun 2021 at 11:55, Peng Yu <pengyu.ut@gmail.com> wrote:
>> >
>> >> I have already done profiling and found an awk program to be a
>> >> bottleneck.
>> >>
>> >> I also tried the —profile option to make sure there is nothing in the
>> >> awk program to be improved.
>> >>
>> >> Although it is slow, it would not be worthwhile to manually translate
>> >> awk code to C as the C code would be too complicated and hard to
>> >> maintain.
>> >>
>> >> Therefore, I am looking for an automatic way to speed up an awk
>> >> program.
>> >>
>> >> On Wed, Jun 30, 2021 at 2:40 AM Bob Proulx <bob@proulx.com> wrote:
>> >>
>> >> > Peng Yu wrote:
>> >> > > I am trying to speed up awk programs. But I don't find a working
>> >> > solution.
>> >> > >
>> >> > > I see this program which compiles awk code into C. But I don't
>> >> > > know where its source package is.
>> >> > >
>> >> > > https://www.mkssoftware.com/docs/man1/awkc.1.asp
>> >> >
>> >> > MKS Software, now PTC MKS, is as far as I know proprietary software.
>> >> > I could not find a clear license statement after a search of their
>> >> > site.  MKS has been around a long time.  There is no source
>> >> > available.
>> >> > Although at one time I recall MKS offering a source license.  But
>> >> > it is definitely not Free Software.
>> >> >
>> >> > > Does anybody know what is the current way to speed up awk
>> >> > > programs?
>> >> >
>> >> > Generally programs may be speeded up by using better algorithms.
>> >> > Almost invariably improved algorithms result in the best
>> >> > performance.
>> >> >
>> >> > Before optimizing a program for performance it is necessary to
>> >> > profile the program to understand where the time is being spent.
>> >> > Benchmark and profile to obtain data before any attempt at
>> >> > optimization.
>> >> > "Premature optimization is the root of all evil." --Tony Hoare.
>> >> >
>> >> > https://www.gnu.org/software/gawk/manual/html_node/Profiling.html
>> >> >
>> >> > AWK is an interpreted language.  Interpreted programs intrinsically
>> >> > have some level of program overhead.  If you think you have the
>> >> > best performing algorithms then one might convert to a compiled
>> >> > language such as C, Rust, Go-lang, or other efficient compiled
>> >> > programming language.
>> >> >
>> >> > Bob
>> >> >
>> >> > --
>> >> Regards,
>> >> Peng
>> >>
>> >
>> >
>> > --
>> > Wolfgang Laun
>> >
>> > --
>> Regards,
>> Peng
>
>


-- 
Regards,
Peng



reply via email to

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