Re: TclX loop slow in the default case



On Sep 13, 8:10 pm, Alexandre Ferrieux <alexandre.ferri...@xxxxxxxxx>
wrote:
[...]
Apologies again for explaining this improperly, and thanks for your
patience for repeating this all over your installed versions ;-)

-Alex

You had it right the first time, I was just being dense.

cheat2 by itself doesn't show any difference ... recall that I had to
introduce cheat5 that got me to the right place. Here are cheat2 and
cheat5.

proc cheat2 {var from to body} {
set nbody "set $var $from
while 1 {
$body\n if {\[incr var\] >= $to} break }"
uplevel 1 $nbody
set ::glo $nbody
}

#king cheat
proc cheat5 {var from to body} {
set var {}; cheat2 var $from $to $body
}

In this test I called cheat5 which then calls cheat2 after setting
"var" to get the effect you were after. And thankfully, the diffs are
non-empty!
-----------------------------------------------------------------
n = 1 nCalls = 1 nRuns = 1
tclsh 8.5.3
0.0001 cheat5
ByteCode 0x0x808b080, refCt 1, epoch 4, interp 0x0x8054da0 (epoch 4)
Source "set var 0\n while 1 {\n expr {$var*$var}\n if {[in"
Cmds 6, src 76, inst 70, litObjs 4, aux 0, stkDepth 2, code/src 0.00
Exception ranges 1, depth 1:
0: level 0, loop, pc 15-63, continue 15, break 67
Commands 6:
1: pc 0-5, src 0-8 2: pc 6-68, src 14-75
3: pc 15-31, src 30-45 4: pc 32-63, src 48-74
5: pc 41-44, src 53-60 6: pc 50-59, src 69-73
Command 1: "set var 0"
(0) push1 0 # "var"
(2) push1 1 # "0"
(4) storeScalarStk
(5) pop
Command 2: "while 1 {\n expr {$var*$var}\n if {[incr var] >= 1}
"
(6) startCommand +63 1 # next cmd at pc 69
Command 3: "expr {$var*$var}"
(15) startCommand +16 1 # next cmd at pc 31
(24) push1 0 # "var"
(26) loadScalarStk
(27) push1 0 # "var"
(29) loadScalarStk
(30) mult
(31) pop
Command 4: "if {[incr var] >= 1} break "
(32) startCommand +32 2 # next cmd at pc 64, 2 cmds start here
Command 5: "incr var"
(41) push1 0 # "var"
(43) incrScalarStkImm +1
(45) push1 2 # "1"
(47) ge
(48) jumpFalse1 +14 # pc 62
Command 6: "break"
(50) startCommand +10 1 # next cmd at pc 60
(59) break
(60) jump1 +4 # pc 64
(62) push1 3 # ""
(64) pop
(65) jump1 -50 # pc 15
(67) push1 3 # ""
(69) done

tclsh 8.5.4
0.0001 cheat5
ByteCode 0x0x8066a58, refCt 1, epoch 4, interp 0x0x8054da0 (epoch 4)
Source "set var 0\n while 1 {\n expr {$var*$var}\n if {[in"
Cmds 6, src 76, inst 70, litObjs 4, aux 0, stkDepth 2, code/src 0.00
Exception ranges 1, depth 1:
0: level 0, loop, pc 15-63, continue 15, break 67
Commands 6:
1: pc 0-5, src 0-8 2: pc 6-68, src 14-75
3: pc 15-31, src 30-45 4: pc 32-63, src 48-74
5: pc 41-44, src 53-60 6: pc 50-59, src 69-73
Command 1: "set var 0"
(0) push1 0 # "var"
(2) push1 1 # "0"
(4) storeScalarStk
(5) pop
Command 2: "while 1 {\n expr {$var*$var}\n if {[incr var] >= 1}
"
(6) startCommand +63 1 # next cmd at pc 69
Command 3: "expr {$var*$var}"
(15) startCommand +16 1 # next cmd at pc 31
(24) push1 0 # "var"
(26) loadScalarStk
(27) push1 0 # "var"
(29) loadScalarStk
(30) mult
(31) pop
Command 4: "if {[incr var] >= 1} break "
(32) startCommand +32 2 # next cmd at pc 64, 2 cmds start here
Command 5: "incr var"
(41) push1 0 # "var"
(43) incrScalarStkImm +1
(45) push1 2 # "1"
(47) ge
(48) jumpFalse1 +14 # pc 62
Command 6: "break"
(50) startCommand +10 1 # next cmd at pc 60
(59) break
(60) jump1 +4 # pc 64
(62) push1 3 # ""
(64) pop
(65) jump1 -50 # pc 15
(67) push1 3 # ""
(69) done

tclsh 8.6a2
0.0001 cheat5
ByteCode 0x0x80bfef8, refCt 1, epoch 5, interp 0x0x8054d68 (epoch 5)
Source "set var 0\n while 1 {\n expr {$var*$var}\n if {[in"
Cmds 6, src 76, inst 68, litObjs 4, aux 0, stkDepth 2, code/src 0.00
Exception ranges 1, depth 1:
0: level 0, loop, pc 14-61, continue 14, break 65
Commands 6:
1: pc 0-4, src 0-8 2: pc 5-66, src 14-75
3: pc 14-30, src 30-45 4: pc 31-61, src 48-74
5: pc 40-42, src 53-60 6: pc 48-57, src 69-73
Command 1: "set var 0"
(0) push1 0 # "0"
(2) storeScalar1 %v0
(4) pop
Command 2: "while 1 {\n expr {$var*$var}\n if {[incr var] >= 1}
"
(5) startCommand +62 1 # next cmd at pc 67
Command 3: "expr {$var*$var}"
(14) startCommand +16 1 # next cmd at pc 30
(23) push1 1 # "var"
(25) loadScalarStk
(26) push1 1 # "var"
(28) loadScalarStk
(29) mult
(30) pop
Command 4: "if {[incr var] >= 1} break "
(31) startCommand +31 2 # next cmd at pc 62, 2 cmds start here
Command 5: "incr var"
(40) incrScalar1Imm %v0 +1
(43) push1 2 # "1"
(45) ge
(46) jumpFalse1 +14 # pc 60
Command 6: "break"
(48) startCommand +10 1 # next cmd at pc 58
(57) break
(58) jump1 +4 # pc 62
(60) push1 3 # ""
(62) pop
(63) jump1 -49 # pc 14
(65) push1 3 # ""
(67) done

tclsh 20080908
0.0001 cheat5
ByteCode 0x0x81da738, refCt 1, epoch 5, interp 0x0x8151d68 (epoch 5)
Source "set var 0\n while 1 {\n expr {$var*$var}\n if {[in"
Cmds 6, src 76, inst 68, litObjs 4, aux 0, stkDepth 2, code/src 0.00
Exception ranges 1, depth 1:
0: level 0, loop, pc 14-61, continue 14, break 65
Commands 6:
1: pc 0-4, src 0-8 2: pc 5-66, src 14-75
3: pc 14-30, src 30-45 4: pc 31-61, src 48-74
5: pc 40-42, src 53-60 6: pc 48-57, src 69-73
Command 1: "set var 0"
(0) push1 0 # "0"
(2) storeScalar1 %v0
(4) pop
Command 2: "while 1 {\n expr {$var*$var}\n if {[incr var] >= 1}
"
(5) startCommand +62 1 # next cmd at pc 67
Command 3: "expr {$var*$var}"
(14) startCommand +16 1 # next cmd at pc 30
(23) push1 1 # "var"
(25) loadScalarStk
(26) push1 1 # "var"
(28) loadScalarStk
(29) mult
(30) pop
Command 4: "if {[incr var] >= 1} break "
(31) startCommand +31 2 # next cmd at pc 62, 2 cmds start here
Command 5: "incr var"
(40) incrScalar1Imm %v0 +1
(43) push1 2 # "1"
(45) ge
(46) jumpFalse1 +14 # pc 60
Command 6: "break"
(48) startCommand +10 1 # next cmd at pc 58
(57) break
(58) jump1 +4 # pc 62
(60) push1 3 # ""
(62) pop
(63) jump1 -49 # pc 14
(65) push1 3 # ""
(67) done

tclsh 20080909
0.0001 cheat5
ByteCode 0x0x81cc520, refCt 1, epoch 5, interp 0x0x8151d68 (epoch 5)
Source "set var 0\n while 1 {\n expr {$var*$var}\n if {[in"
Cmds 6, src 76, inst 66, litObjs 3, aux 0, stkDepth 2, code/src 0.00
Exception ranges 1, depth 1:
0: level 0, loop, pc 14-59, continue 14, break 63
Commands 6:
1: pc 0-4, src 0-8 2: pc 5-64, src 14-75
3: pc 14-28, src 30-45 4: pc 29-59, src 48-74
5: pc 38-40, src 53-60 6: pc 46-55, src 69-73
Command 1: "set var 0"
(0) push1 0 # "0"
(2) storeScalar1 %v0
(4) pop
Command 2: "while 1 {\n expr {$var*$var}\n if {[incr var] >= 1}
"
(5) startCommand +60 1 # next cmd at pc 65
Command 3: "expr {$var*$var}"
(14) startCommand +14 1 # next cmd at pc 28
(23) loadScalar1 %v0
(25) loadScalar1 %v0
(27) mult
(28) pop
Command 4: "if {[incr var] >= 1} break "
(29) startCommand +31 2 # next cmd at pc 60, 2 cmds start here
Command 5: "incr var"
(38) incrScalar1Imm %v0 +1
(41) push1 1 # "1"
(43) ge
(44) jumpFalse1 +14 # pc 58
Command 6: "break"
(46) startCommand +10 1 # next cmd at pc 56
(55) break
(56) jump1 +4 # pc 60
(58) push1 2 # ""
(60) pop
(61) jump1 -47 # pc 14
(63) push1 2 # ""
(65) done

-----------------------------------------------------------------

If you will ... maestro

.



Relevant Pages

  • Max Extents and Extents size from intrinsic FFILEINFO
    ... Stan: ... match MPEiX's LISTF,3 command nor Vesoft's LISTF,-3 ... Now that I have those two working successfully I have found that FFILEINFO ... var formal_designator: char36; ...
    (comp.sys.hp.mpe)
  • Re: BASH help please??
    ... IFS= read var ... String length greater than width! ... command already has its stdin connected to a pipe. ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • WAY OT: pushing data bits
    ... "Maybe the command to tell ... OWFERst CON %0001 'Front-End Reset ... CRem1 VAR Byte ... PAUSE 1000 'open debug window ...
    (rec.crafts.metalworking)
  • Re: Reintroducing fish, the friendly interactive shell
    ... Is that any different in fish? ... Fish does not allow you to use a variable as a command. ... command line stored in $var. ... expands to 1 argument which is the content of $var is $var is ...
    (comp.unix.shell)
  • Re: Please help
    ... here command is any shell command the output of command will be ... set var ... and that Tcl neither interprets nor expands glob ...
    (comp.lang.tcl)