xiaoasX
Deno3y ago
xiaoas

Following deno_core code execution is slower

So I have the following code, which is taken from https://github.com/denoland/deno/tree/main/core/examples and edited for simple benchmarking:
use std::time::Instant;

use deno_core::v8;
use deno_core::JsRuntime;
use deno_core::RuntimeOptions;

fn main() {
    let mut runtime = JsRuntime::new(RuntimeOptions::default());

    // Evaluate some code
    let code = "let a = 1+4; a*2";
    for _ in 0..10 {
        let instant = Instant::now();
        runtime.execute_script_static("<anon>", code);
        println!("{:?}", instant.elapsed());
    }
}

Which outputs the following:
28.809µs
321.455µs
181.944µs
132.383µs
128.343µs
121.826µs
119.734µs
114.393µs
131.579µs
162.282µs

the second run seems to be significantly slower than the first. Is this a performance bug? Or am I using the runtime incorrectly?
GitHub
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.
Was this page helpful?