Martin Lužák
Martin Lužák
>Home>About me>Projects
LinkedInEmailMy side projects
status: building
>Home>About me>Projects
status: building

Let's Talk

Let's create something meaningful

Technology is at its best when it serves people. Whether you're looking for guidance, collaboration, or a fresh perspective, let's start a conversation.

more information about me→

Find me elsewhere

LinkedIn
/in/martinluzak
Email
hello@martinluzak.sk
ProjectsMy side projects
/projects
Forged with& code

© 2026 Martin Lužák — Human heart. Technical logic. AI assisted.

back to blog
systems

Rust + WebAssembly Performance Deep Dive

Benchmarking Rust compiled to WebAssembly vs native JavaScript. When does WASM shine and when to stick with JS?

ML

Martin Lužák

Software Engineer

Sep 18, 202411 min read
#rust#wasm#performance

The Performance Question

WebAssembly promises near-native performance in the browser. But is it always faster than JavaScript? Let's find out with real benchmarks.

Test Setup

We'll compare three scenarios:

  • Pure JavaScript
  • Rust compiled to WASM
  • Rust WASM with JS interop
  • Benchmark 1: Fibonacci (CPU-bound)

    // Rust
    

    #[wasm_bindgen]

    pub fn fibonacci(n: u32) -> u32 {

    match n {

    0 => 0,

    1 => 1,

    _ => fibonacci(n - 1) + fibonacci(n - 2)

    }

    }

    // JavaScript
    

    function fibonacci(n) {

    if (n <= 1) return n;

    return fibonacci(n - 1) + fibonacci(n - 2);

    }

    Results (fib(40), 100 iterations):
    • JavaScript: 1,245ms
    • Rust WASM: 892ms
    • WASM wins by 28%

    Benchmark 2: Array Processing

    Processing 1M elements with map/reduce operations. Results:

    • JavaScript: 45ms
    • Rust WASM: 52ms (with copy overhead)
    • Rust WASM SharedArrayBuffer: 23ms
    • WASM wins only with shared memory

    When to Use WASM

    Use WASM for:
    • Heavy computation (image processing, cryptography)
    • Games and simulations
    • Porting existing C/C++/Rust codebases
    Stick with JS for:
    • DOM manipulation
    • Light data processing
    • When bundle size matters

    Conclusion

    WASM isn't a silver bullet. The overhead of crossing the JS-WASM boundary can negate performance gains for small operations. Profile first, optimize second.

    share
    share:
    [RELATED_POSTS]

    Continue Reading

    systems

    Understanding LTI: Integrating Learning Tools with Educational Platforms

    A comprehensive guide to Learning Tools Interoperability (LTI) 1.3 - the standard protocol that enables seamless integration between learning management systems and external educational tools.

    Jan 7, 2026•18 min read