/
githubmirror
/
tauri
Обзор
Документация
Войти
/
githubmirror
/
tauri
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
bench/src/build_benchmark_jsons.rs
69 строк
2 KB
Tony
ci: benchmark on all platforms (#15486)
09 июн 2026, 10:56
Не верифицирован
09 июн 2026, 10:56
6d99a8f
Код
Авторство
О чём код?
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT //! This Rust binary runs on CI and provides internal metrics results of Tauri. To learn more see [benchmark_results](https://github.com/tauri-apps/benchmark_results) repository. //! //! ***_Internal use only_** #![doc( html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/.github/icon.png", html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/.github/icon.png" )] // file is used by multiple binaries #![allow(dead_code)] use std::{fs::File, io::BufReader}; mod utils; fn main() { let platform = if cfg!(target_os = "macos") { "macos" } else if cfg!(target_os = "windows") { "windows" } else { "linux" }; let tauri_data = &utils::tauri_root_path() .join("gh-pages") .join(format!("tauri-data-{platform}.json")); let tauri_recent = &utils::tauri_root_path() .join("gh-pages") .join(format!("tauri-recent-{platform}.json")); // current data let current_data_buffer = BufReader::new( File::open(utils::target_dir().join("bench.json")).expect("Unable to read current data file"), ); let current_data: utils::BenchResult = serde_json::from_reader(current_data_buffer).expect("Unable to read current data buffer"); // all data's let all_data_buffer = BufReader::new(File::open(tauri_data).expect("Unable to read all data file")); let mut all_data: Vec<utils::BenchResult> = serde_json::from_reader(all_data_buffer).expect("Unable to read all data buffer"); // add current data to all data all_data.push(current_data); // use only latest 20 elements from all data let recent: Vec<utils::BenchResult> = if all_data.len() > 20 { all_data[all_data.len() - 20..].to_vec() } else { all_data.clone() }; // write json's utils::write_json( tauri_data, &serde_json::to_value(&all_data).expect("Unable to build final json (all)"), ) .unwrap_or_else(|_| panic!("Unable to write {}", tauri_data.display())); utils::write_json( tauri_recent, &serde_json::to_value(recent).expect("Unable to build final json (recent)"), ) .unwrap_or_else(|_| panic!("Unable to write {}", tauri_recent.display())); }