Skip to content

Commit

Permalink
Fix warnings and run rustfmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranchuFranchu committed Feb 29, 2024
1 parent 9fd3a99 commit bbbd666
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
14 changes: 7 additions & 7 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use hvmc::{
ast::{Book, Net},
host::Host,
run::{Net as RtNet, Strict},
util::create_host,
};
use std::{
fs,
Expand Down Expand Up @@ -60,24 +60,24 @@ fn run_file(path: &PathBuf, group: Option<String>, c: &mut Criterion) {

fn benchmark(file_name: &str, book: Book, c: &mut Criterion) {
let area = RtNet::<Strict>::init_heap(1 << 29);
let host = Host::new(&book);
let host = create_host(&book);
c.bench_function(file_name, |b| {
b.iter(|| {
let mut net = RtNet::<Strict>::new(&area);
net.boot(host.defs.get("main").unwrap());
net.boot(host.lock().unwrap().defs.get("main").unwrap());
black_box(black_box(net).normal())
});
});
}

fn benchmark_group(file_name: &str, group: String, book: Book, c: &mut Criterion) {
let area = RtNet::<Strict>::init_heap(1 << 29);
let host = Host::new(&book);
let host = create_host(&book);

c.benchmark_group(group).bench_function(file_name, |b| {
b.iter(|| {
let mut net = RtNet::<Strict>::new(&area);
net.boot(host.defs.get("main").unwrap());
net.boot(host.lock().unwrap().defs.get("main").unwrap());
black_box(black_box(net).normal())
});
});
Expand All @@ -99,11 +99,11 @@ fn interact_benchmark(c: &mut Criterion) {
let mut book = Book::default();
book.insert("main".to_string(), Net { root: Era, rdex: vec![redex] });
let area = RtNet::<Strict>::init_heap(1 << 24);
let host = Host::new(&book);
let host = create_host(&book);
group.bench_function(name, |b| {
b.iter(|| {
let mut net = RtNet::<Strict>::new(&area);
net.boot(host.defs.get("main").unwrap());
net.boot(host.lock().unwrap().defs.get("main").unwrap());
black_box(black_box(net).normal())
});
});
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::{
path::Path,
process::{self, Stdio},
str::FromStr,
sync::{Arc, Mutex},
time::{Duration, Instant},
};

Expand Down Expand Up @@ -288,7 +287,6 @@ fn load_book(files: &[String], compile_opts: &CompileArgs) -> Book {
book
}


fn reduce_exprs(host: &Host, exprs: &[Net], opts: &RuntimeOpts) {
let heap = run::Net::<Strict>::init_heap_bytes(opts.memory as usize);
for expr in exprs {
Expand Down
11 changes: 8 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use crate::{
ast::{Book, Net, Tree}, host::{DefRef, Host}, run::Rewrites
ast::{Book, Net, Tree},
host::{DefRef, Host},
run::Rewrites,
};
use std::{
sync::{Arc, Mutex},
time::Duration,
};
use std::{sync::{Arc, Mutex}, time::Duration};

/// Creates a variable uniquely identified by `id`.
pub(crate) fn create_var(mut id: usize) -> String {
Expand Down Expand Up @@ -263,4 +268,4 @@ pub fn create_host(book: &Book) -> Arc<Mutex<Host>> {
);
host.lock().unwrap().insert_book(&book);
host
}
}
7 changes: 6 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use std::{
fs, io::{self, Write}, path::{Path, PathBuf}, str::FromStr, sync::{Arc, Mutex}, time::Instant
fs,
io::{self, Write},
path::{Path, PathBuf},
str::FromStr,
sync::{Arc, Mutex},
time::Instant,
};

use hvmc::{
Expand Down

0 comments on commit bbbd666

Please sign in to comment.