proc doNothing args {
    set args
}

proc build {cmd lst} {
    linsert $lst 0 $cmd
}

proc expandMostArgsA lst {
    for {set i $::num} {$i} {incr i -1} {
	doNothing A {expand}$lst B
    }
}

proc expandMostArgsB lst {
    for {set i $::num} {$i} {incr i -1} {
	doNothing {expand}$lst A B 
    }
}

proc expandFewArgsA lst {
    for {set i $::num} {$i} {incr i -1} {
	doNothing \
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    {expand}$lst \
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10
    }
}

proc expandFewArgsB lst {
    for {set i $::num} {$i} {incr i -1} {
	doNothing \
	    {expand}$lst \
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10\
	    1 2 3 4 5 6 7 8 9 10
    }
}

proc expandCmd lst {
    for {set i $::num} {$i} {incr i -1} {
	{expand}$lst
    }
}

proc evalCmd lst {
    for {set i $::num} {$i} {incr i -1} {
	eval $lst
    }
}

set iter 20
set num 100

# FALTA: expand few args

foreach i {1 10 100 1000 2000}  {
    set thisLst [split [string repeat a $i] ""]
    bench -desc "EXPAND most args A $i" -iter $iter \
	-body {expandMostArgsA $thisLst}
    bench -desc "EXPAND most args B $i" -iter $iter \
	-body {expandMostArgsB $thisLst}
    bench -desc "EXPAND few args A $i" -iter $iter \
	-body {expandFewArgsA $thisLst}
    bench -desc "EXPAND few args B $i" -iter $iter \
	-body {expandFewArgsB $thisLst}
    set thisCmd [build doNothing $thisLst]
    bench -desc "EXPAND cmd $i" -iter $iter \
	-body {expandCmd $thisCmd}
    bench -desc "EXPAND eval cmd $i" -iter $iter \
	-body {evalCmd $thisCmd}
}
	
	