This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
57 lines (44 loc) · 1.36 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use clap::{Parser, Subcommand};
use rayon::prelude::*;
use std::path::Path;
use frame_view_tools_lib::*;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
struct Args {
/// Path to FrameView CSV file
#[clap(short = 'i', long = "in", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
in_file: std::path::PathBuf,
#[clap(subcommand)]
command: Commands,
}
// TODO: Average frame time
// TODO: Average temp(s)
// TODO: Overview command (A nice print out of the averages and stats)
#[derive(Subcommand, Debug)]
enum Commands {
/// Outputs the average FPS
AverageFPS,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
match &args.command {
Commands::AverageFPS => average_fps(args.in_file.as_path()),
}
}
fn average_fps(path: &Path) {
let entry_vec: Vec<FrameViewCSVEntry> = deserialize_csv_into_vec(path);
let mut vec_of_frame_times = Vec::new();
for entry in entry_vec {
match entry.ms_between_presents {
None => {}
Some(x) => {
vec_of_frame_times.push(x);
}
}
}
let vec_of_fps: Vec<f64> = vec_of_frame_times.par_iter().map(|x| 1000f64 / x).collect();
let average: f64 = vec_of_fps.par_iter().sum::<f64>() / vec_of_fps.len() as f64;
println!("{:?}", average)
}