@@ -12,6 +12,16 @@ fn run_original_prodigal(
1212 input_file : & str ,
1313 output_file : & str ,
1414 threads : Option < usize > ,
15+ ) -> Result < Duration , Box < dyn std:: error:: Error > > {
16+ run_original_prodigal_with_mode ( input_file, output_file, threads, "single" )
17+ }
18+
19+ // Helper function to run original prodigal with specified mode
20+ fn run_original_prodigal_with_mode (
21+ input_file : & str ,
22+ output_file : & str ,
23+ threads : Option < usize > ,
24+ mode : & str ,
1525) -> Result < Duration , Box < dyn std:: error:: Error > > {
1626 let start = std:: time:: Instant :: now ( ) ;
1727
@@ -23,7 +33,7 @@ fn run_original_prodigal(
2333 . arg ( "-f" )
2434 . arg ( "gff" )
2535 . arg ( "-p" )
26- . arg ( "single" ) ;
36+ . arg ( mode ) ;
2737
2838 // Original prodigal doesn't have threading, but we include this for consistency
2939 if threads. is_some ( ) {
@@ -49,6 +59,16 @@ fn run_pyrodigal(
4959 input_file : & str ,
5060 output_file : & str ,
5161 threads : Option < usize > ,
62+ ) -> Result < Duration , Box < dyn std:: error:: Error > > {
63+ run_pyrodigal_with_mode ( input_file, output_file, threads, "single" )
64+ }
65+
66+ // Helper function to run pyrodigal with specified mode
67+ fn run_pyrodigal_with_mode (
68+ input_file : & str ,
69+ output_file : & str ,
70+ threads : Option < usize > ,
71+ mode : & str ,
5272) -> Result < Duration , Box < dyn std:: error:: Error > > {
5373 let start = std:: time:: Instant :: now ( ) ;
5474
@@ -60,7 +80,7 @@ fn run_pyrodigal(
6080 . arg ( "-f" )
6181 . arg ( "gff" )
6282 . arg ( "-p" )
63- . arg ( "single" ) ;
83+ . arg ( mode ) ;
6484
6585 if let Some ( t) = threads {
6686 cmd. arg ( "-j" ) . arg ( t. to_string ( ) ) ;
@@ -85,6 +105,16 @@ fn run_orphos_cli(
85105 input_file : & str ,
86106 output_file : & str ,
87107 threads : Option < usize > ,
108+ ) -> Result < Duration , Box < dyn std:: error:: Error > > {
109+ run_orphos_cli_with_mode ( input_file, output_file, threads, "single" )
110+ }
111+
112+ // Helper function to run orphos with specified mode
113+ fn run_orphos_cli_with_mode (
114+ input_file : & str ,
115+ output_file : & str ,
116+ threads : Option < usize > ,
117+ mode : & str ,
88118) -> Result < Duration , Box < dyn std:: error:: Error > > {
89119 let start = std:: time:: Instant :: now ( ) ;
90120
@@ -106,7 +136,7 @@ fn run_orphos_cli(
106136 . arg ( "-f" )
107137 . arg ( "gff" )
108138 . arg ( "-p" )
109- . arg ( "single" ) ;
139+ . arg ( mode ) ;
110140
111141 let output = cmd. output ( ) ?;
112142 let duration = start. elapsed ( ) ;
@@ -426,11 +456,109 @@ fn benchmark_scaling_analysis(c: &mut Criterion) {
426456 group. finish ( ) ;
427457}
428458
459+ /// Benchmark meta mode (metagenomic) - single threaded comparison
460+ fn benchmark_meta_mode_single_threaded ( c : & mut Criterion ) {
461+ let test_files = [
462+ ( "ecoli" , "tests/data/ecoli.fasta" ) ,
463+ ( "salmonella" , "tests/data/salmonella.fasta" ) ,
464+ ] ;
465+
466+ for ( name, input_file) in test_files {
467+ if !Path :: new ( input_file) . exists ( ) {
468+ eprintln ! ( "Warning: {} not found, skipping benchmark" , input_file) ;
469+ continue ;
470+ }
471+
472+ let file_size = get_file_size ( input_file) ;
473+ let mut group = c. benchmark_group ( format ! ( "{}_meta_single_threaded" , name) ) ;
474+ group. throughput ( Throughput :: Bytes ( file_size) ) ;
475+
476+ // Check if original prodigal is available
477+ if Command :: new ( "prodigal" ) . arg ( "--help" ) . output ( ) . is_ok ( ) {
478+ group. bench_function ( "original_prodigal_meta" , |b| {
479+ b. iter_custom ( |iters| {
480+ let mut total_duration = Duration :: new ( 0 , 0 ) ;
481+ for _ in 0 ..iters {
482+ let output_file = NamedTempFile :: new ( ) . unwrap ( ) ;
483+ let duration = run_original_prodigal_with_mode (
484+ black_box ( input_file) ,
485+ output_file. path ( ) . to_str ( ) . unwrap ( ) ,
486+ None ,
487+ "meta" ,
488+ )
489+ . unwrap_or_else ( |e| {
490+ eprintln ! ( "Original prodigal meta benchmark failed: {}" , e) ;
491+ Duration :: from_secs ( 0 )
492+ } ) ;
493+ total_duration += duration;
494+ }
495+ total_duration
496+ } ) ;
497+ } ) ;
498+ } else {
499+ eprintln ! (
500+ "Warning: Original prodigal not found, skipping original_prodigal_meta benchmark"
501+ ) ;
502+ }
503+
504+ // Check if pyrodigal is available
505+ if Command :: new ( "pyrodigal" ) . arg ( "--help" ) . output ( ) . is_ok ( ) {
506+ group. bench_function ( "pyrodigal_meta" , |b| {
507+ b. iter_custom ( |iters| {
508+ let mut total_duration = Duration :: new ( 0 , 0 ) ;
509+ for _ in 0 ..iters {
510+ let output_file = NamedTempFile :: new ( ) . unwrap ( ) ;
511+ let duration = run_pyrodigal_with_mode (
512+ black_box ( input_file) ,
513+ output_file. path ( ) . to_str ( ) . unwrap ( ) ,
514+ Some ( 1 ) ,
515+ "meta" ,
516+ )
517+ . unwrap_or_else ( |e| {
518+ eprintln ! ( "Pyrodigal meta benchmark failed: {}" , e) ;
519+ Duration :: from_secs ( 0 )
520+ } ) ;
521+ total_duration += duration;
522+ }
523+ total_duration
524+ } ) ;
525+ } ) ;
526+ } else {
527+ eprintln ! ( "Warning: Pyrodigal not found, skipping pyrodigal_meta benchmark" ) ;
528+ }
529+
530+ // Benchmark orphos meta mode (single-threaded)
531+ group. bench_function ( "orphos_meta" , |b| {
532+ b. iter_custom ( |iters| {
533+ let mut total_duration = Duration :: new ( 0 , 0 ) ;
534+ for _ in 0 ..iters {
535+ let output_file = NamedTempFile :: new ( ) . unwrap ( ) ;
536+ let duration = run_orphos_cli_with_mode (
537+ black_box ( input_file) ,
538+ output_file. path ( ) . to_str ( ) . unwrap ( ) ,
539+ Some ( 1 ) ,
540+ "meta" ,
541+ )
542+ . unwrap_or_else ( |e| {
543+ eprintln ! ( "orphos-cli meta benchmark failed: {}" , e) ;
544+ Duration :: from_secs ( 0 )
545+ } ) ;
546+ total_duration += duration;
547+ }
548+ total_duration
549+ } ) ;
550+ } ) ;
551+
552+ group. finish ( ) ;
553+ }
554+ }
555+
429556criterion_group ! (
430557 name = benches;
431558 config = configure_criterion( ) ;
432559 targets = benchmark_single_threaded,
433560 // benchmark_multi_threaded,
434- benchmark_scaling_analysis
561+ benchmark_scaling_analysis,
562+ benchmark_meta_mode_single_threaded
435563) ;
436564criterion_main ! ( benches) ;
0 commit comments