-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d95a761
commit d863418
Showing
10 changed files
with
175 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use ::Digits; | ||
|
||
pub enum CliReporter { | ||
TickerTape, | ||
Spinner, | ||
} | ||
|
||
impl CliReporter { | ||
#[inline] | ||
pub fn report(&self, data: &Digits) { | ||
match *self { | ||
ref _thingy @ CliReporter::TickerTape => ::reporter::ticker_tape::report(data), | ||
ref _thingy @ CliReporter::Spinner => ::reporter::spinner::report(data), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod report_data; | ||
pub mod cli_reporter; | ||
pub mod work_load; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::time::SystemTime; | ||
extern crate serde; | ||
use self::serde::ser::{Serialize, Serializer, SerializeStruct}; | ||
use std::sync::{Arc, Mutex}; | ||
use ::{ITERATIONS,SUCCESS}; | ||
use std::sync::atomic::Ordering; | ||
use std::ops::Deref; | ||
|
||
#[derive(Clone)] | ||
pub struct ReportData { | ||
pub cores: u8, | ||
pub chunk: usize, | ||
pub cluster: Option<(usize,usize)>, | ||
pub character_set: String, | ||
pub start_time: SystemTime, | ||
pub start_at: String, | ||
pub adjacent_limit: Option<u8>, | ||
pub five_min_progress: Arc<Mutex<(usize, String)>> | ||
} | ||
|
||
impl Serialize for ReportData { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where S: Serializer { | ||
|
||
let mut struct_fields = 9; | ||
if self.cluster.is_some() { struct_fields += 2; } | ||
if self.adjacent_limit.is_some() { struct_fields += 1; } | ||
|
||
let mut state = serializer.serialize_struct("ReportData", struct_fields)?; | ||
state.serialize_field("cores", &self.cores)?; | ||
state.serialize_field("chunk", &self.chunk)?; | ||
if let Some((node, cluster_size)) = self.cluster { | ||
state.serialize_field("cluster_node", &node)?; | ||
state.serialize_field("cluster_size", &cluster_size)?; | ||
} | ||
state.serialize_field("character_set", &self.character_set)?; | ||
state.serialize_field("start_time", &self.start_time)?; | ||
state.serialize_field("start_at", &self.start_at)?; | ||
if let Some(adj) = self.adjacent_limit { | ||
state.serialize_field("adjacent_limit", &adj)?; | ||
} | ||
state.serialize_field("iterations", &ITERATIONS.load(Ordering::SeqCst))?; | ||
let getter = self.five_min_progress.lock().unwrap(); | ||
let &(five_min_iters, ref last_string) = getter.deref(); | ||
state.serialize_field("last_five_minute_iterations", &five_min_iters)?; | ||
state.serialize_field("last_attempt", &last_string)?; | ||
state.serialize_field("success", &SUCCESS.load(Ordering::SeqCst))?; | ||
state.end() | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use ::Digits; | ||
use ::model::report_data::ReportData; | ||
use ::model::cli_reporter::CliReporter; | ||
|
||
pub struct WorkLoad( | ||
pub String, // characters: String, | ||
pub usize, // max: usize, | ||
pub Digits, // mut sequencer: Digits, | ||
pub String, // target: String, | ||
pub Option<String>, // adj: Option<String> | ||
pub Option<String>, // chunk: Option<String> | ||
pub Option<usize>, // cluster_step: Option<(usize,usize)> | ||
pub ReportData, // cloned ReportData for web JSON results and other reporters | ||
pub CliReporter, // cli Reporter chosen | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,2 @@ | ||
pub mod ticker_tape; | ||
pub mod spinner; | ||
use ::Digits; | ||
|
||
#[derive(Debug)] | ||
pub enum CliReporter { | ||
TickerTape, | ||
Spinner, | ||
} | ||
|
||
impl CliReporter { | ||
#[inline] | ||
pub fn report(&self, data: &Digits) { | ||
match *self { | ||
ref _thingy @ CliReporter::TickerTape => ticker_tape::report(data), | ||
ref _thingy @ CliReporter::Spinner => spinner::report(data), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.