-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vhf and ultimate indicators (#12)
- Loading branch information
Showing
4 changed files
with
150 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,44 @@ | ||
//use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
// | ||
//use traquer::*; | ||
// | ||
//pub fn criterion_benchmark(c: &mut Criterion) { | ||
// c.bench_function("fib 20", |b| b.iter(|| black_box(main()))); | ||
//} | ||
// | ||
//criterion_group!(benches, criterion_benchmark); | ||
//criterion_main!(benches); | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use std::fs; | ||
|
||
use traquer::indicator; | ||
|
||
#[divan::bench] | ||
fn run() { | ||
divan::black_box(traquer::main()); | ||
#[derive(Deserialize, Serialize, Debug)] | ||
struct SecStats { | ||
high: Vec<f64>, | ||
low: Vec<f64>, | ||
open: Vec<f64>, | ||
close: Vec<f64>, | ||
volume: Vec<f64>, | ||
} | ||
|
||
fn main() { | ||
divan::main(); | ||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let data = fs::read_to_string("./aapl.input").expect("Unable to read file"); | ||
let stats: SecStats = serde_json::from_str(&data).expect("JSON does not have correct format."); | ||
c.bench_function("fib 20", |b| { | ||
b.iter(|| { | ||
black_box(indicator::ultimate( | ||
&stats.high, | ||
&stats.low, | ||
&stats.close, | ||
6, | ||
12, | ||
24, | ||
)) | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); | ||
|
||
//#[divan::bench] | ||
//fn run() { | ||
// divan::black_box(traquer::main()); | ||
//} | ||
// | ||
//fn main() { | ||
// divan::main(); | ||
//} |
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