Once you have some proper benchmarks, it might be fun to compare GoAWK's performance to that of my awk package.
I don't know how much performance difference this makes in practice, but my value struct (also in a value.go file) lazily converts among strings, floats, and ints and caches the conversions. I don't keep track of "the" type of a value (your typ field), just whether I have a currently valid string/float/int representation.
No need to change your lexer/parser at this stage, but I've recently grown quite fond of PEG parsers. These are a lot like hand-rolled, recursive-descent parsers so they're relatively easy to wrap your head around and reasonably powerful but require less code/effort than actually rolling your own. For Go, I've used pigeon for a few projects (e.g., edif2qmasm, for which a PEG parser is probably overkill). I like pigeon, but I admit I didn't do a thorough analysis of all the available PEG parsers for Go before going with that one.
Nice work!
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/kYZp3Q1KKfE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
Once you have some proper benchmarks, it might be fun to compare GoAWK's performance to that of my awk package.Nice -- will do!
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Once you have some proper benchmarks, it might be fun to compare GoAWK's performance to that of my awk package.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/kYZp3Q1KKfE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
https://benhoyt.com/writings/goawk/It's pretty much a toy project, not being used for anything real, but it seems to be in a good shape. Feedback welcome!
> - also enable normal go program to use awk scriptsprobably this is better tool for the case
Hope there are future plans to extend it so that,- people can define user function in go and use it in goawk handling, as kty... has pointed out.
- also enable normal go program to use awk scripts
probably this is better tool for the case- please don't just post a link, but include descriptions.- please justify your claim "better" - a specific log file parser is better than general-purpose awk scripts? In what way?- please don't hijack a thread in promoting your own tool, especially when it is highly irreverent.
For what it's worth, I found that tool quite interesting and relevant. Tong, I think you're overreacting a bit here.
So my main suggestion (for spakin/awk) would be able to wrap os.Stdout in a bufio.NewWriter (and be sure to call Flush before Run finishes). If the user wants to pass an unbuffered version, they still can, but at least the default is performant.I also added CPU profiling to the spakin/awk script, and it looks like it's doing a bunch more garbage collection than GoAWK, as well as some regexp stuff. I suspect NewValue() is probably quite slow as it takes an interface{} and does type checking. Also, strings are converted to numbers using a regex, which is probably slower than a dedicated conversion/check function (see parseFloatPrefix in goawk/interp/value.go).See more optimization ideas in my post at https://benhoyt.com/writings/goawk/
I wonder if it makes sense, to expose more of the interpreter to go.E.g.: register a user function or add an action written in go.