#!/usr/bin/env perl

use 5.010;
use strict;
use warnings;

use Benchmark::Command;

my $code_noop   = q|$SPEC{noop}={v=>1.1}; sub noop { [200,"OK",""] } Perinci::CmdLine::Lite->new(url=>"/main/noop")->run|;

my $code_int    = q|$SPEC{int}={v=>1.1, args=>{arg1=>{schema=>"int"}}}; sub int { [200,"OK",""] } Perinci::CmdLine::Lite->new(url=>"/main/int")->run|;

my $code_str_in = q|$SPEC{str_in}={v=>1.1, args=>{arg1=>{schema=>["str*", in=>[qw/foo bar baz/]]}}}; sub str_in { [200,"OK",""] } Perinci::CmdLine::Lite->new(url=>"/main/str_in")->run|;

# ::Any only adds <1ms of overhead, no need to bench it

Benchmark::Command::run(0, {
    'perl'              => [$^X, "-e1"],
    'load'              => [$^X, "-MPerinci::CmdLine::Lite", "-e", 1],

    'run_noop'          => [$^X, "-MPerinci::CmdLine::Lite", "-e", $code_noop],

    'run_int'           => [$^X, "-MPerinci::CmdLine::Lite", "-e", $code_int, "--", "--arg1", "1"],
    'run_int (comp)'    => [{env=>{COMP_LINE=>"foo --arg1 ", COMP_POINT=>11}}, $^X, "-MPerinci::CmdLine::Lite", "-e", $code_int],

    'run_str_in'        => [$^X, "-MPerinci::CmdLine::Lite", "-e", $code_str_in, "--", "--arg1", "foo"],
    'run_str_in (comp)' => [{env=>{COMP_LINE=>"foo --arg1 ", COMP_POINT=>11}}, $^X, "-MPerinci::CmdLine::Lite", "-e", $code_str_in],
});
