9 ms·
Anyone has tried modifying the go regex benchmark to use https://github.com/BurntSushi/rure-go https://github.com/BurntSushi/rure-go ? It seems to use a library
by Aissen 8y ago
Anyone has tried modifying the go regex benchmark to use https://github.com/BurntSushi/rure-go https://github.com/BurntSushi/rure-go ? It seems to use a library that isn't even on github anymore.
- ysleepy 8y ago"Go bindings to Rust's regex engine." - I't would not be in the spirit of the comparison. - Even though most scripting languages also have native regex implementations.
- burntsushi 8y agoThe fastest Go benchmark for regex-redux is using PCRE, which is not a native Go regex engine. It's written in C.
- Aissen 8y agoPrecisely my point. Most scripting languages also use an engine written in C, too, as grandparent said.
- burntsushi 8y agoI had fun with this: [andrew@Cheetah benchgame] time bench-native < /tmp/input5000000.txt ... real 0m20.709s user 1m19.839s sys 0m0.183s [andrew@Cheetah benchgame] time bench-pcre < /tmp/input5000000.txt ... real 0m10.510s user 0m35.362s sys 0m0.211s [andrew@Cheetah benchgame] time bench-rust < /tmp/input5000000.txt ... real 0m2.235s user 0m3.410s sys 0m0.157s For comparison, this is the timing for the Rust program, unchanged from the benchmark site: $ time ./target/release/bench-rust-regex < /tmp/input5000000.txt ... real 0m1.452s user 0m2.643s sys 0m0.158s See https://gist.github.com/BurntSushi/9d35258444fda83de208d31fdd5e9e69 https://gist.github.com/BurntSushi/9d35258444fda83de208d31fd... for source code and full results. And no, I won't submit this myself, although I would find it absolutely hilarious if someone did and managed to get it in. :-) The PCRE version is definitely sub-optimal. I don't think it's using the JIT, for example. Enabling SIMD optimizations in Rust's regex crate shaves off another 13% (for Rust program) and 9% (for Go program). The SIMD optimizations will be enabled by default in Rust 1.27 for CPUs that support them.
- Aissen 8y agoAwesome work, thanks !
- Aissen 8y agoThis looked fun, so I did my own micro-benchmark on an rpi3, armv7 : $ for i in bench-native bench-pcre bench-pcrejit bench-rure; do echo -n $i; (cd $i; time ./$i < ../input500000.txt > /dev/null) ; echo; done bench-native real 0m24,883s user 0m56,580s sys 0m0,120s bench-pcre real 0m13,125s user 0m27,200s sys 0m0,160s bench-pcrejit real 0m2,688s user 0m3,140s sys 0m0,120s bench-rure real 0m2,779s user 0m3,300s sys 0m0,090s It looks like pcre with JIT enabled is always faster than the rure version, but this is very close.