mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
Introduce a pause after calling Cursive.step (#3326)
Currently we call it in a loop without any delays which burns cpu cycles for little value. On my machine I see decrease of cpu usage from 12% to 6% on a synced node after applying this fix.
This commit is contained in:
parent
133a8da53e
commit
93f5de3d29
1 changed files with 3 additions and 0 deletions
|
@ -29,6 +29,7 @@ use cursive::utils::markup::StyledString;
|
||||||
use cursive::views::{BoxedView, CircularFocus, Dialog, LinearLayout, Panel, StackView, TextView};
|
use cursive::views::{BoxedView, CircularFocus, Dialog, LinearLayout, Panel, StackView, TextView};
|
||||||
use cursive::Cursive;
|
use cursive::Cursive;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
use std::{thread, time};
|
||||||
|
|
||||||
use crate::built_info;
|
use crate::built_info;
|
||||||
use crate::servers::Server;
|
use crate::servers::Server;
|
||||||
|
@ -187,6 +188,7 @@ impl Controller {
|
||||||
pub fn run(&mut self, server: Server) {
|
pub fn run(&mut self, server: Server) {
|
||||||
let stat_update_interval = 1;
|
let stat_update_interval = 1;
|
||||||
let mut next_stat_update = Utc::now().timestamp() + stat_update_interval;
|
let mut next_stat_update = Utc::now().timestamp() + stat_update_interval;
|
||||||
|
let delay = time::Duration::from_millis(50);
|
||||||
while self.ui.step() {
|
while self.ui.step() {
|
||||||
if let Some(message) = self.rx.try_iter().next() {
|
if let Some(message) = self.rx.try_iter().next() {
|
||||||
match message {
|
match message {
|
||||||
|
@ -205,6 +207,7 @@ impl Controller {
|
||||||
self.ui.ui_tx.send(UIMessage::UpdateStatus(stats)).unwrap();
|
self.ui.ui_tx.send(UIMessage::UpdateStatus(stats)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
thread::sleep(delay);
|
||||||
}
|
}
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue