I reran the results on my m1 mac pro since this post is 6 years old:
python etree: 3.25s
python lxml: 2.01s
go stdlib: 3.35s
go gosax: 1.45s
C: 0.38s
So, python etree gives the same result 6 years on while lxml has gotten faster. Go's standard library does about as well as python's stdlib, and has gotten faster on the cgo binding.Procedure:
- clone https://github.com/eliben/xmlgen
- run `xmlgen -f 2 > out.xml` to generate a test xml file
- clone https://github.com/eliben/code-for-blog/ and switch to the 2019/xml-stream dir
- mv out.xml from above to the current directory
- `time python etree-count.py out.xml`
- `pip install lxml && time python lxml-count.py out.xml`
- `go build go-stdlib-count.go && time ./go-stdlib-count out.xml`
- `cd c-libxmlsax-count && make && time ./c-libxmlsax-count ../out.xml`
- `cd gosax-count && go build gosax-count-simple.go && time ./gosax-count-simple ../out.xml`