xiaoas
xiaoas
DDeno
Created by xiaoas on 10/8/2024 in #help
How to use set_internal_field of rusty v8?
After checking the process demo it seems that set_internal_field_count was called, but no actual value was set. So I'm wondering 1. is it possible to use this feature in rusty_v8? 2. In the cpp example SetNativeDataProperty & SetHandler(NamedPropertyHandlerConfiguration(MapGet, MapSet)) were used. Is it possible to do the same in rusty_v8?
2 replies
DDeno
Created by xiaoas on 4/13/2023 in #help
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());
}
}
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
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?
1 replies