This gets you https://play.golang.org/p/J8hFZyyFF8 about 25% perf boost:

BenchmarkDecode-8          30000             43268 ns/op
BenchmarkUnmarshal-8       30000             43195 ns/op
BenchmarkManual-8          50000             30216 ns/op

Also, Decode/Unmarshal seem pretty equal.

If you don't need full xml spec, then you probably can implement a faster 
parser. (Maybe one already exists https://godoc.org/?q=xml)

And... if you can avoid XML for this, then avoid it. It's not ideal for 
this.

+ Egon

On Wednesday, 8 February 2017 07:22:35 UTC+2, emarti...@gmail.com wrote:
>
> Hello,
>
> I'm making a go code which is basically parsing a lot of small xml 
> responses. I've noticed that right after I enable the parsing code, my R/S 
> as per wrk, as well as response times drop to 15% for some reason. I'm 
> testing with about 2000 concurrent clients and each one parses about 50 
> very small xmls (1 entry each). 
>
> Below is my code, does anyone have any experience/feedback with xml 
> decoding performance on go?
>
>
> package main
>
>
> import (
>     "encoding/xml"
>     "bytes"
> )
>
>
> type DBXML struct{
>     HostProperties  DBXML_HostProperties
>     Listing            DBXML_Listing
> }
>
> type DBXML_Listing struct {
>     sid string
>     Original_title string `xml:"title"`
>     Original_desc   string `xml:"desc"`
>     Original_domain   string `xml:"display_url"`
>     Original_bid   float64 `xml:"bid"`
>     Original_URL   string `xml:"clickurl"`
> }
>
> type DBXML_HostProperties struct {
>     Tags    []DBXML_Listing    `xml:"record"`
> }
>
> func (r *DBXML ) parse_response (data []byte) bool {
>     reader := bytes.NewReader(data)
>     decoder := xml.NewDecoder(reader)
>     decoder.Decode(&r.HostProperties);
>
>     //xml.Unmarshal(data, &r.HostProperties) // With this one i got even 
> less performance.
>
> }
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to