Skip to content

Commit

Permalink
feat: adds profile binary
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Jan 1, 2025
1 parent 8ecf847 commit 31a1ce6
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[profile.release-with-debug]
inherits = "release"
debug = true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ target/
rustc-ice*

.idea

flamegraph.svg
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"omics-core",
"omics-molecule",
"omics-variation",
"profile",
]
resolver = "2"

Expand All @@ -21,6 +22,7 @@ rust-version = "1.80.0"
anyhow = "1.0.89"
criterion = "0.5.1"
regex = "1.9.6"
string-interner = "0.18.0"
thiserror = "2.0.4"

[workspace.lints.rust]
Expand Down
19 changes: 19 additions & 0 deletions profile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "profile"
version = "0.1.0"
license.workspace = true
edition.workspace = true
authors.workspace = true
description.workspace = true
homepage.workspace = true
repository.workspace = true
rust-version.workspace = true
publish = false

[dependencies]
omics-coordinate = { path = "../omics-coordinate" }

clap = { version = "4", features = ["derive"] }

[lints]
workspace = true
28 changes: 28 additions & 0 deletions profile/src/contig.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Profiling of contigs.
pub mod alloc;

use clap::Parser;
use clap::Subcommand;

/// The different aspects of contigs that can be profiled.
#[derive(Subcommand)]
pub enum Command {
/// Allocations of contigs.
Alloc(alloc::Args),
}

/// Profiling of contigs.
#[derive(Parser)]
pub struct Args {
/// The subcommand.
#[command(subcommand)]
command: Command,
}

/// The main method.
pub fn main(args: Args) {
match args.command {
Command::Alloc(args) => alloc::main(args),
}
}
21 changes: 21 additions & 0 deletions profile/src/contig/alloc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Profiling of contig allocations.
use std::hint::black_box;

use clap::Parser;
use omics_coordinate::Contig;

/// Profiling of contig allocations.
#[derive(Parser, Debug)]
pub struct Args {
/// The number of allocations to use.
#[arg(default_value_t = 100_000_000)]
n: usize,
}

/// The main method.
pub fn main(args: Args) {
for _ in 0..args.n {
let _ = black_box(Contig::new("seq0"));
}
}
30 changes: 30 additions & 0 deletions profile/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! A profiling tool for developing `omics`.
use clap::Parser;
use clap::Subcommand;

pub mod contig;

/// The different entities that can be profiled.
#[derive(Subcommand)]
pub enum Command {
/// Contig profiling.
Contig(contig::Args),
}

/// Profiling of `omics` entities.
#[derive(Parser)]
pub struct Args {
/// The subcommand.
#[command(subcommand)]
command: Command,
}

/// The main method.
pub fn main() {
let args = Args::parse();

match args.command {
Command::Contig(args) => contig::main(args),
}
}

0 comments on commit 31a1ce6

Please sign in to comment.