56 lines
1.2 KiB
Rust
56 lines
1.2 KiB
Rust
use std::sync::OnceLock;
|
|
|
|
use chrono::{Local, NaiveDate};
|
|
use gix::{features::hash::Sha1, ObjectId};
|
|
use libgitheatmap::{
|
|
heatmap::{self, Heatmap},
|
|
Commit,
|
|
};
|
|
|
|
static COMMITS: OnceLock<Vec<Commit>> = OnceLock::new();
|
|
|
|
fn main() {
|
|
let mut commits: Vec<Commit> = vec![];
|
|
for _n in 0..1000 {
|
|
let id = ObjectId::Sha1(Sha1::default().digest());
|
|
let title = mockd::words::sentence(10);
|
|
let author = mockd::name::full();
|
|
let email = mockd::contact::email();
|
|
let time = mockd::datetime::date_range(
|
|
"2024-01-01T00:00:00Z".to_string(),
|
|
"2025-01-01T00:00:00Z".to_string(),
|
|
)
|
|
.with_timezone(&Local);
|
|
commits.push(Commit::new(id, title, author, email, time));
|
|
}
|
|
|
|
COMMITS.set(commits).expect("unable to generate commits");
|
|
|
|
divan::main();
|
|
}
|
|
|
|
#[divan::bench]
|
|
fn heatmap_generation() {
|
|
let since = NaiveDate::parse_from_str("2024-01-01", "%Y-%m-%d").unwrap();
|
|
|
|
let until = NaiveDate::parse_from_str("2025-01-01", "%Y-%m-%d").unwrap();
|
|
|
|
let commits_vec = COMMITS
|
|
.get()
|
|
.expect("unable to access commits list")
|
|
.to_vec();
|
|
let commits = commits_vec.len();
|
|
let repos = 1;
|
|
|
|
let _heatmap = Heatmap::new(
|
|
since,
|
|
until,
|
|
commits,
|
|
repos,
|
|
commits_vec,
|
|
false,
|
|
13,
|
|
heatmap::Format::Chars,
|
|
);
|
|
}
|