2023-08-06 08:25:04 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-08-16 11:52:07 -04:00
|
|
|
use std::env;
|
2022-07-19 19:29:41 -04:00
|
|
|
|
2023-08-06 08:25:04 -04:00
|
|
|
use criterion::{Criterion, criterion_group, criterion_main};
|
2024-04-16 21:26:01 -04:00
|
|
|
use physis::common::Platform;
|
2024-04-15 17:52:05 -04:00
|
|
|
use physis::index::IndexFile;
|
2023-08-06 08:25:04 -04:00
|
|
|
|
2022-07-19 19:29:41 -04:00
|
|
|
fn reload_repos() {
|
|
|
|
let game_dir = env::var("FFXIV_GAME_DIR").unwrap();
|
2024-04-16 21:26:01 -04:00
|
|
|
physis::gamedata::GameData::from_existing(Platform::Win32, format!("{}/game", game_dir).as_str()).unwrap();
|
2022-07-19 19:29:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_calculate_hash() {
|
2024-04-15 17:52:05 -04:00
|
|
|
IndexFile::calculate_hash("exd/root.exl");
|
2022-07-19 19:29:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn fetch_data() {
|
|
|
|
let game_dir = env::var("FFXIV_GAME_DIR").unwrap();
|
2022-08-16 11:52:07 -04:00
|
|
|
let mut gamedata =
|
2024-04-16 21:26:01 -04:00
|
|
|
physis::gamedata::GameData::from_existing(Platform::Win32, format!("{}/game", game_dir).as_str()).unwrap();
|
|
|
|
|
2022-07-19 19:29:41 -04:00
|
|
|
gamedata.extract("exd/root.exl");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn criterion_benchmark(c: &mut Criterion) {
|
2022-08-16 11:50:18 -04:00
|
|
|
c.bench_function("hash calc", |b| b.iter(bench_calculate_hash));
|
2024-04-15 17:52:05 -04:00
|
|
|
|
|
|
|
#[cfg(feature = "retail_game_testing")]
|
|
|
|
{
|
|
|
|
c.bench_function("gamedata reloading repositories", |b| b.iter(reload_repos));
|
|
|
|
c.bench_function("gamedata extract", |b| b.iter(fetch_data));
|
|
|
|
}
|
2022-07-19 19:29:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
2022-08-16 11:52:07 -04:00
|
|
|
criterion_main!(benches);
|