Simple benchmarks and performance improvements

- added some simple benchmarks
- basic perf improvements (low hanging fruits, JS-specific, see individual commits)
- fixed a bug with realloc on empty buffer