fix: patch Instance::now
This commit is contained in:
@@ -13,7 +13,7 @@ use crate::{
|
||||
use crate::{JsError, JsNativeError};
|
||||
use boa_interner::ToInternedString;
|
||||
use boa_profiler::Profiler;
|
||||
use std::{convert::TryInto, mem::size_of, time::Instant};
|
||||
use std::{convert::TryInto, mem::size_of};
|
||||
|
||||
mod call_frame;
|
||||
mod code_block;
|
||||
@@ -216,13 +216,18 @@ impl Context<'_> {
|
||||
.code_block
|
||||
.instruction_operands(&mut pc, self.interner());
|
||||
|
||||
let instant = Instant::now();
|
||||
// wasm32 not supports `Instant::now()`
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let instant = std::time::Instant::now();
|
||||
let result = self.execute_instruction();
|
||||
let duration = instant.elapsed();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let duration_micros = -1;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let duration_micros = instant.elapsed().as_micros();
|
||||
|
||||
println!(
|
||||
"{:<TIME_COLUMN_WIDTH$} {:<OPCODE_COLUMN_WIDTH$} {operands:<OPERAND_COLUMN_WIDTH$} {}",
|
||||
format!("{}μs", duration.as_micros()),
|
||||
format!("{}μs", duration_micros),
|
||||
opcode.as_str(),
|
||||
match self.vm.stack.last() {
|
||||
Some(value) if value.is_callable() => "[function]".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user