Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/improve chart performance #224

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src-tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,42 @@ impl AppState {
.analysis
.insert(name, disk_analysis);
}
pub fn emit_sysinfo(&self, app: &tauri::AppHandle) {
pub async fn emit_sysinfo(&self, app: &tauri::AppHandle) {
let sys_info = self.0.lock().unwrap().metrics.get_system_information();
app.emit("emit_sysinfo", &sys_info).unwrap();
}

pub fn emit_global_cpu(&self, app: &tauri::AppHandle) {
pub async fn emit_global_cpu(&self, app: &tauri::AppHandle) {
let global_cpu = self.0.lock().unwrap().metrics.get_global_cpu();
app.emit("emit_global_cpu", &global_cpu).unwrap();
}

pub fn emit_cpus(&self, app: &tauri::AppHandle) {
pub async fn emit_cpus(&self, app: &tauri::AppHandle) {
let cpus = self.0.lock().unwrap().metrics.get_cpus();
app.emit("emit_cpus", &cpus).unwrap();
}

pub fn emit_memory(&self, app: &tauri::AppHandle) {
pub async fn emit_memory(&self, app: &tauri::AppHandle) {
let memory = self.0.lock().unwrap().metrics.get_memory();
app.emit("emit_memory", &memory).unwrap();
}

pub fn emit_swap(&self, app: &tauri::AppHandle) {
pub async fn emit_swap(&self, app: &tauri::AppHandle) {
let swap = self.0.lock().unwrap().metrics.get_swap();
app.emit("emit_swap", &swap).unwrap();
}

pub fn emit_networks(&self, app: &tauri::AppHandle) {
pub async fn emit_networks(&self, app: &tauri::AppHandle) {
let networks = self.0.lock().unwrap().metrics.get_networks();
app.emit("emit_networks", &networks).unwrap();
}

pub fn emit_disks(&self, app: &tauri::AppHandle) {
pub async fn emit_disks(&self, app: &tauri::AppHandle) {
let disks = self.0.lock().unwrap().metrics.get_disks();
app.emit("emit_disks", &disks).unwrap();
}

pub fn emit_processes(&self, app: &tauri::AppHandle) {
pub async fn emit_processes(&self, app: &tauri::AppHandle) {
let processes = self.0.lock().unwrap().metrics.get_processes();
app.emit("emit_processes", &processes).unwrap();
}
Expand Down
24 changes: 16 additions & 8 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod utils;

use app::AppState;
use tauri::menu::Menu;
use tokio::time;

use std::time::Duration;

Expand All @@ -38,14 +39,21 @@ fn build_and_run_app(app: AppState) {

tauri::async_runtime::spawn(async move {
loop {
state.emit_sysinfo(&handle);
state.emit_global_cpu(&handle);
state.emit_cpus(&handle);
state.emit_memory(&handle);
state.emit_swap(&handle);
state.emit_networks(&handle);
state.emit_disks(&handle);
state.emit_processes(&handle);
state.emit_sysinfo(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_global_cpu(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_cpus(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_memory(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_swap(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_networks(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_disks(&handle).await;
std::thread::sleep(Duration::from_millis(100));
state.emit_processes(&handle).await;
std::thread::sleep(Duration::from_secs(1))
}
});
Expand Down
28 changes: 27 additions & 1 deletion src/components/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const useAreaChartState = (
// This is the rectangle box that u can use to navigate
navigator: {
adaptToUpdatedData: true,

maskFill: other.charts.area.default.navigator.maskFill,
handles: {
backgroundColor: other.charts.area.default.navigator.handles.backgroundColor,
Expand All @@ -53,6 +54,29 @@ export const useAreaChartState = (

plotOptions: {
series: {
boostThreshold: 1,
turboThreshold: 1,
showInNavigator: true,

// dataGrouping: {
// enabled: true,
// anchor: "start",
// forced: true,
// groupAll: true,
// units: [
// [
// "millisecond", // unit name
// [1, 2, 5, 10, 20, 25, 50, 100, 200, 500], // allowed multiples
// ],
// ["second", [1, 2, 5, 10, 15, 30]],
// ["minute", [1, 2, 5, 10, 15, 30]],
// ["hour", [1, 2, 3, 4, 6, 8, 12]],
// ["day", [1]],
// ["week", [1]],
// ["month", [1, 3, 6]],
// ["year", null],
// ],
// },
marker: {
enabled: false,
},
Expand Down Expand Up @@ -173,7 +197,9 @@ export const useAreaChartState = (
},
boost: {
enabled: true,
useGPUTranslations: false,

usePreallocated: true,
useGPUTranslations: true,
allowForce: true,
},
chart: {
Expand Down
Loading