README.md

October 3, 2020 · View on GitHub

Benchmarks

This compares 4 projects:

There are be some differences in the datastructures between javascript and the port to rust, but I think these differences are idiomatic. Overall the algorithms are implemented in a similar way and behave equally, the tests were also ported. Everything is singlethreaded.

Test


for (var i = 0; i < 1000; i++) {
    wanakana.toKana('aiueosashisusesonaninunenokakikukeko')
    wanakana.toKana('AIUEOSASHISUSESONANINUNENOKAKIKUKEKO')
    wanakana.toHiragana('aiueosashisusesonaninunenokakikukeko')
    wanakana.toHiragana('アイウエオサシスセソナニヌネノカキクケコ')
    wanakana.toKatakana('aiueosashisusesonaninunenokakikukeko')
    wanakana.toKatakana('あいうえおさしすせそなにぬねのかきくけこ')
    wanakana.toRomaji('あいうえおさしすせそなにぬねのかきくけこ')
    wanakana.toRomaji('アイウエオサシスセソナニヌネノカキクケコ')
}

Results

Num Loopsjavascriptrustwasm (rust)node with rust bindings
1_000Wall Time[ms]25397218
Wall Time Relative28x1x8x2x
100_000Wall Time[ms]16149195937833131
Wall Time Relative8,2x1x1,93x1,59x
1_000_000Wall Time[ms]181879219563688531294
Wall Time Relative8,2x1x1,67x1,42x

Conclusion

It can make sense to port performance sensitive code to wasm if total compatiblity is required (e.g. browser and node support, or no rust compiler feasible). More gains are possible when using native rust code or calling rust from nodejs.

Open

No analysis regarding memory analysis has been done yet.