Skip to content

Commit 8b9647f

Browse files
committed
node: add basic skipping
The mighty skip comes to node, putting it nearly in the range of the compiled languages. Even though it isn't as fast as the compiled languages, this is still objectively fast. Unless the file is already cached in memory, you're well into the realm of being i/o bound instead of node being the bottleneck.
1 parent d70c7f4 commit 8b9647f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ implementations compare to each other.
7979
| simple (Rust) | 0m1.461s | 0m1.325s | 0m0.131s |
8080
| skip (Rust) | 0m0.231s | 0m0.105s | 0m0.124s |
8181
| simple (Node) | 0m6.458s | 0m6.043s | 0m0.627s |
82+
| skip (Node) | 0m1.368s | 0m1.062s | 0m0.686s |
8283
| custom (C) | **0m0.222s** | **0m0.079s** | **0m0.141s** |
8384

8485
By comparing the times you can see that each implementation is more or less

Diff for: main.js

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ function is_hex(c) {
3737
function scan_slice(buf) {
3838
let count = 0;
3939
for (let i = 0; i< buf.length; i++) {
40+
if (count === 0 && i+20 < buf.length && !is_hex(buf[i+20])) {
41+
i += 20;
42+
continue;
43+
}
4044
if (is_hex(buf[i])) {
4145
count++;
4246
continue;

0 commit comments

Comments
 (0)