Skip to content

Commit

Permalink
feat: added more intel cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Jan 24, 2024
1 parent 2a86158 commit 32ceeaa
Show file tree
Hide file tree
Showing 9 changed files with 898 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ impl CpuCache {
/// and return it. For example, it might take an input of "AMD Ryzen 5 3600 6-Core Processor",
/// and return the entry with a `name` of "AMD Ryzen™ 5 3600"
pub fn find(&self, input: &str) -> Cpu {
// let input_str = String::from("AMD Ryzen 5 3600 6-Core Processor");
let input_model = find_model(&input);
let input_model = find_model(input);
// a list of CPUs, and the most likely
let cpus = if input.contains("AMD") {
&self.amd_cpus
Expand Down
161 changes: 161 additions & 0 deletions src/cpu/intel/chunks/1.csv

Large diffs are not rendered by default.

163 changes: 163 additions & 0 deletions src/cpu/intel/chunks/2.csv

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions src/cpu/intel/chunks/3.csv

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions src/cpu/intel/chunks/4.csv

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions src/cpu/intel/chunks/5.csv

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions src/cpu/intel/chunks/6.csv

Large diffs are not rendered by default.

31 changes: 25 additions & 6 deletions src/cpu/intel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,39 @@ mod parser;

// This csv was obtained by going to https://ark.intel.com/content/www/us/en/ark/search/featurefilter.html?productType=873,
// selecting a filter that includes every single processor (eg, 1 core to [max] cores) -> Compare all -> Compare -> Export Comparison
// note: you need to actually manually load everything in for the csv to contain everything, if the number of cpus being compared doesn't seem
// correct, it's probably not actually every cpu
const FILE_CONTENTS: &str = include_str!("input.csv");

// update: I have found the best way to actually get every cpu is to go through the process of loading every cpu onto your webpage, find the table element containing
// all of the cpus -> right click -> create global variable -> iterate over `temp1.children` and extract`element.getAttribute("data-product-id")
// from there, you can generate a list of urls based off of <https://ark.intel.com/content/www/us/en/ark/compare.html?productIds=> and that list of ids
// you generated earlier.
// You can also apparently extract an sqlite DB from the android app <https://github.com/issy/intel-ark-api>, that may be worth looking into,
// although when i checked, it looked slightly out of date

// this list should contain every intel core processor (not ultra) up till 14th gen
// TODO: make this list contain *every* intel processor
const CHUNKS: [&str; 6] = [
include_str!("chunks/1.csv"),
include_str!("chunks/2.csv"),
include_str!("chunks/3.csv"),
include_str!("chunks/4.csv"),
include_str!("chunks/5.csv"),
include_str!("chunks/6.csv"),
];

pub fn get_intel_cpus() -> Vec<Cpu> {
parse_csv(FILE_CONTENTS).unwrap()
let mut merged_vec: Vec<Cpu> = Vec::with_capacity(1024);
for chunk in CHUNKS {
merged_vec.append(&mut parse_csv(chunk).unwrap());
}
merged_vec
}

#[cfg(test)]
mod tests {
use super::{parser::parse_csv, FILE_CONTENTS};
use super::{parser::parse_csv, CHUNKS};

#[test]
fn it_work() {
parse_csv(FILE_CONTENTS).unwrap();
parse_csv(CHUNKS[0]).unwrap();
}
}
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ struct CpuQuery {
pub name: String,
}

/// This handler accepts a json in the form of a [CpuQuery]
/// ```json
/// {
/// "name": "SEARCH_QUERY"
/// }
/// ```
/// It relies on a globally shared [AppState] to re-use the cpu cache, and responds to the request with a serialized [Cpu].
/// It will always attempt to find a cpu, and should always return a cpu. The correctness of the return value is not guaranteed.
async fn get_cpu_handler(State(state): State<AppState>, Json(query): Json<CpuQuery>) -> Json<Cpu> {
// just to get type annotations working
let state: AppState = state;

Json(state.cpu_cache.find(&query.name))

}

#[tokio::main]
Expand Down

0 comments on commit 32ceeaa

Please sign in to comment.