revme/cmd/
bench.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pub mod analysis;
pub mod burntpix;
pub mod snailtracer;
pub mod transfer;

use clap::{Parser, ValueEnum};

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
pub enum BenchName {
    Analysis,
    Burntpix,
    Snailtracer,
    Transfer,
}

impl BenchName {
    pub const ALL: &[BenchName] = &[
        BenchName::Analysis,
        BenchName::Burntpix,
        BenchName::Snailtracer,
        BenchName::Transfer,
    ];

    pub fn as_str(self) -> &'static str {
        match self {
            BenchName::Analysis => "analysis",
            BenchName::Burntpix => "burntpix",
            BenchName::Snailtracer => "snailtracer",
            BenchName::Transfer => "transfer",
        }
    }
}

/// `bytecode` subcommand
#[derive(Parser, Debug)]
pub struct Cmd {
    #[arg(value_enum)]
    pub name: BenchName,
}

impl Cmd {
    /// Runs bench command.
    pub fn run(&self) {
        match self.name {
            BenchName::Analysis => analysis::run(),
            BenchName::Burntpix => burntpix::run(),
            BenchName::Snailtracer => snailtracer::run(),
            BenchName::Transfer => transfer::run(),
        }
    }
}