Skip to content

Commit

Permalink
Remove lazy static dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Nov 28, 2024
1 parent 522529e commit d6b62c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cc = "1.0"
[dev-dependencies]
criterion = "0.5.1"
proptest = "1.5.0"
lazy_static = "1.4.0"

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
jemallocator = "0.5.0"
Expand Down
20 changes: 8 additions & 12 deletions examples/check_real_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Under linux, we choose to use smem, which can monitor memory changes more accurately

use ckb_vm::{run_with_memory, Bytes, FlatMemory, SparseMemory};
use lazy_static::lazy_static;
use std::process::{id, Command};

#[cfg(has_asm)]
Expand All @@ -17,11 +16,8 @@ use ckb_vm::{
#[cfg(has_asm)]
use std::thread;

lazy_static! {
pub static ref BIN_PATH_BUFFER: Bytes =
Bytes::from(&include_bytes!("../tests/programs/alloc_many")[..]);
pub static ref BIN_NAME: String = format!("alloc_many");
}
static BIN_PATH_BUFFER: &'static [u8] = include_bytes!("../tests/programs/alloc_many");
static BIN_NAME: &str = "alloc_many";

#[cfg(not(target_os = "windows"))]
#[global_allocator]
Expand Down Expand Up @@ -128,8 +124,8 @@ fn check_interpreter(memory_size: usize) -> Result<(), ()> {
println!("Base memory: {}", get_current_memory());
for _ in 0..G_CHECK_LOOP {
let result = run_with_memory::<u64, SparseMemory<u64>>(
&BIN_PATH_BUFFER,
&vec![BIN_NAME.clone().into()],
&Bytes::from(BIN_PATH_BUFFER),
&vec![Bytes::from(BIN_NAME)],
SparseMemory::new_with_memory(memory_size),
);
assert!(result.is_ok());
Expand All @@ -148,8 +144,8 @@ fn check_falt(memory_size: usize) -> Result<(), ()> {
println!("Base memory: {}", get_current_memory());
for _ in 0..G_CHECK_LOOP {
let result = run_with_memory::<u64, FlatMemory<u64>>(
&BIN_PATH_BUFFER,
&vec![BIN_NAME.clone().into()],
&Bytes::from(BIN_PATH_BUFFER),
&vec![Bytes::from(BIN_NAME)],
FlatMemory::new_with_memory(memory_size),
);
assert!(result.is_ok());
Expand All @@ -172,7 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
let core = DefaultMachineBuilder::new(asm_core).build();
let mut machine = AsmMachine::new(core);
machine
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
.unwrap();
let result = machine.run();
assert!(result.is_ok());
Expand All @@ -196,7 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
let core = DefaultMachineBuilder::new(asm_core).build();
let mut machine = AsmMachine::new(core);
machine
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
.unwrap();
let thread_join_handle = thread::spawn(move || {
let result = machine.run();
Expand Down

0 comments on commit d6b62c8

Please sign in to comment.