-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mpapierski/update-parser
Update parser
- Loading branch information
Showing
23 changed files
with
365 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
extern crate casper_wasm; | ||
extern crate time; | ||
|
||
use std::fs; | ||
use time::Instant; | ||
|
||
#[cfg(feature = "std")] | ||
fn rate(file_name: &'static str, iterations: u64) { | ||
use std::fs; | ||
|
||
use std::time::{Duration, Instant}; | ||
|
||
let file_size = fs::metadata(file_name) | ||
.unwrap_or_else(|_| panic!("{} to exist", file_name)) | ||
.len(); | ||
let mut total_ms = 0; | ||
let mut total = Duration::from_secs(0); | ||
|
||
for _ in 0..iterations { | ||
let start = Instant::now(); | ||
let _module = casper_wasm::deserialize_file(file_name); | ||
let end = Instant::now(); | ||
let end = start.elapsed(); | ||
|
||
total_ms += (end - start).whole_milliseconds(); | ||
total += end; | ||
} | ||
|
||
println!( | ||
"Rate for {}: {} MB/s", | ||
file_name, | ||
(file_size as f64 * iterations as f64 / (1024*1024) as f64) / // total work megabytes | ||
(total_ms as f64 / 1000f64) // total seconds | ||
(file_size as f64 * iterations as f64 / (1024*1024) as f64) / // total work megabytes | ||
(total.as_millis() as f64 / 1000f64) // total seconds | ||
); | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
fn main() { | ||
rate("./res/cases/v1/clang.wasm", 10); | ||
rate("./res/cases/v1/hello.wasm", 100); | ||
rate("./res/cases/v1/with_names.wasm", 100); | ||
} | ||
#[cfg(not(feature = "std"))] | ||
fn main() { | ||
panic!("Compilation requires --feature std") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[toolchain] | ||
channel = "1.84.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.