Update Wasmer, log load times, some minor performance tweaks
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use chrono::Duration;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
@@ -24,18 +25,45 @@ use pkmn_lib::static_data::{
|
||||
};
|
||||
use pkmn_lib::StringKey;
|
||||
|
||||
pub fn load_library() -> Arc<dyn DynamicLibrary> {
|
||||
pub struct LoadResult {
|
||||
pub library: Arc<dyn DynamicLibrary>,
|
||||
pub types_load_time: Duration,
|
||||
pub natures_load_time: Duration,
|
||||
pub items_load_time: Duration,
|
||||
pub growth_rate_load_time: Duration,
|
||||
pub abilities_load_time: Duration,
|
||||
pub moves_load_time: Duration,
|
||||
pub species_load_time: Duration,
|
||||
pub wasm_load_time: Duration,
|
||||
}
|
||||
|
||||
pub fn load_library() -> LoadResult {
|
||||
let mut path = get_project_root().unwrap();
|
||||
path.push("tests/data/");
|
||||
let path = path.to_str().unwrap().to_string();
|
||||
|
||||
let t1 = chrono::Utc::now();
|
||||
let types = load_types(&path);
|
||||
let t2 = chrono::Utc::now();
|
||||
let types_load_time = t2 - t1;
|
||||
let natures = load_natures(&path);
|
||||
let t1 = chrono::Utc::now();
|
||||
let natures_load_time = t1 - t2;
|
||||
let items = load_items(&path);
|
||||
let t2 = chrono::Utc::now();
|
||||
let items_load_time = t2 - t1;
|
||||
let growth_rates = load_growth_rates(&path);
|
||||
let t1 = chrono::Utc::now();
|
||||
let growth_rate_load_time = t1 - t2;
|
||||
let abilities = load_abilities(&path);
|
||||
let t2 = chrono::Utc::now();
|
||||
let abilities_load_time = t2 - t1;
|
||||
let moves = load_moves(&path, &types);
|
||||
let t1 = chrono::Utc::now();
|
||||
let moves_load_time = t1 - t2;
|
||||
let species = load_species(&path, &types, &moves);
|
||||
let t2 = chrono::Utc::now();
|
||||
let species_load_time = t2 - t1;
|
||||
|
||||
let data = StaticDataImpl::new(
|
||||
Box::new(LibrarySettingsImpl::new(100)),
|
||||
@@ -47,16 +75,32 @@ pub fn load_library() -> Arc<dyn DynamicLibrary> {
|
||||
natures,
|
||||
abilities,
|
||||
);
|
||||
|
||||
let t1 = chrono::Utc::now();
|
||||
let mut resolver = WebAssemblyScriptResolver::new();
|
||||
load_wasm(&path, resolver.as_mut());
|
||||
let t2 = chrono::Utc::now();
|
||||
let wasm_load_time = t2 - t1;
|
||||
|
||||
Arc::new(DynamicLibraryImpl::new(
|
||||
let library = Arc::new(DynamicLibraryImpl::new(
|
||||
Box::new(data),
|
||||
Box::new(Gen7BattleStatCalculator::new()),
|
||||
Box::new(Gen7DamageLibrary::new(false)),
|
||||
Box::new(Gen7MiscLibrary::new()),
|
||||
resolver,
|
||||
))
|
||||
));
|
||||
|
||||
LoadResult {
|
||||
library,
|
||||
types_load_time,
|
||||
natures_load_time,
|
||||
items_load_time,
|
||||
growth_rate_load_time,
|
||||
abilities_load_time,
|
||||
moves_load_time,
|
||||
species_load_time,
|
||||
wasm_load_time,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_types(path: &String) -> Box<dyn TypeLibrary> {
|
||||
|
||||
Reference in New Issue
Block a user