Skip to content
Merged
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
224 changes: 224 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/devkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

[dev-dependencies]
serde_json = "1"
criterion = { version = "0.5", features = ["html_reports"] }

[[bench]]
name = "fee_model_bench"
harness = false
15 changes: 15 additions & 0 deletions packages/devkit/benches/fee_model_bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use criterion::{criterion_group, criterion_main, Criterion};
use stellar_devkit::simulation::fee_model::{FeeModel, FeeModelConfig};

fn bench_generate_100k(c: &mut Criterion) {
let config = FeeModelConfig {
ledger_count: 100_000,
..Default::default()
};
c.bench_function("fee_model_generate_100k", |b| {
b.iter(|| FeeModel::generate(&config))
});
}

criterion_group!(benches, bench_generate_100k);
criterion_main!(benches);
19 changes: 19 additions & 0 deletions packages/devkit/src/cli/export.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
use crate::simulation::fee_model::FeePoint;
use std::fmt::Write as FmtWrite;

/// Exports devkit results to external formats.
pub struct Export;

impl Export {
/// Serialize fee points to CSV string with columns: timestamp,fee,ledger,is_spike.
pub fn to_csv(points: &[FeePoint]) -> String {
let mut out = String::from("timestamp,fee,ledger,is_spike\n");
for p in points {
writeln!(out, "{},{},{},{}", p.timestamp, p.fee, p.ledger, p.is_spike).unwrap();
}
out
}

/// Write fee points to a CSV file.
pub fn write_csv(points: &[FeePoint], path: &std::path::Path) -> std::io::Result<()> {
std::fs::write(path, Self::to_csv(points))
}
}
2 changes: 2 additions & 0 deletions packages/devkit/src/harness/scenarios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ impl ScenarioRotator {
}
}

use std::path::Path;

/// Loads a scenario JSON file from the given path and returns its contents.
pub fn load_from_file(path: &Path) -> std::io::Result<String> {
std::fs::read_to_string(path)
Expand Down
Loading
Loading