#!/bin/sh # Another timing test for obstcl \ exec tclsh80 "$0" "$@" # Make sure we're loaded. Assume we are in the test directory lappend auto_path [file dirname [pwd]] package require obstcl # catch {delete class Dummy} defclass Dummy { inherit Object option foo constructor {} {} method dummy {} {} variable nothing {} } # Create three sizes of class defclass ::Foo0 { inherit ::Object variable foo0 {} method call {x} { return $foo0 } } defclass ::Foo10 { inherit ::Object variable foo0 0 variable foo1 1 variable foo2 2 variable foo3 3 variable foo4 4 variable foo5 5 variable foo6 6 variable foo7 7 variable foo8 8 variable foo9 9 method call {x} { return $foo0 } } defclass ::Foo100 { inherit ::Object variable foo0 0 variable foo1 1 variable foo2 2 variable foo3 3 variable foo4 4 variable foo5 5 variable foo6 6 variable foo7 7 variable foo8 8 variable foo9 9 variable foo10 10 variable foo11 11 variable foo12 12 variable foo13 13 variable foo14 14 variable foo15 15 variable foo16 16 variable foo17 17 variable foo18 18 variable foo19 19 variable foo20 20 variable foo21 21 variable foo22 22 variable foo23 23 variable foo24 24 variable foo25 25 variable foo26 26 variable foo27 27 variable foo28 28 variable foo29 29 variable foo30 30 variable foo31 31 variable foo32 32 variable foo33 33 variable foo34 34 variable foo35 35 variable foo36 36 variable foo37 37 variable foo38 38 variable foo39 39 variable foo40 40 variable foo41 41 variable foo42 42 variable foo43 43 variable foo44 44 variable foo45 45 variable foo46 46 variable foo47 47 variable foo48 48 variable foo49 49 variable foo50 50 variable foo51 51 variable foo52 52 variable foo53 53 variable foo54 54 variable foo55 55 variable foo56 56 variable foo57 57 variable foo58 58 variable foo59 59 variable foo60 60 variable foo61 61 variable foo62 62 variable foo63 63 variable foo64 64 variable foo65 65 variable foo66 66 variable foo67 67 variable foo68 68 variable foo69 69 variable foo70 70 variable foo71 71 variable foo72 72 variable foo73 73 variable foo74 74 variable foo75 75 variable foo76 76 variable foo77 77 variable foo78 78 variable foo79 79 variable foo80 80 variable foo81 81 variable foo82 82 variable foo83 83 variable foo84 84 variable foo85 85 variable foo86 86 variable foo87 87 variable foo88 88 variable foo89 89 variable foo90 90 variable foo91 91 variable foo92 92 variable foo93 93 variable foo94 94 variable foo95 95 variable foo96 96 variable foo97 97 variable foo98 98 variable foo99 99 method call {x} { return $foo0 } } # Measure time to create an object and call a method set unique 0 puts "Create an object with 1 variable: [time {set foo [Foo0 foo[incr unique]]} 10]" puts "Call an object with 1 variable: [time {$foo call 1} 10]" puts "*Call an object with 1 variable: [time {namespace eval Foo0 {call $foo 1}} 10]" set unique 0 puts "Create an object with 10 variables: [time {set foo [Foo10 foo[incr unique]]} 10]" puts "Call an object with 10 variables: [time {$foo call 1} 10]" puts "*Call an object with 10 variables: [time {namespace eval Foo10 {call $foo 1}} 10]" set unique 0 puts "Create an object with 100 variables: [time {set foo [Foo100 foo[incr unique]]} 10]" puts "Call an object with 100 variables: [time {$foo call 1} 10]" puts "*Call an object with 100 variable: [time {namespace eval Foo100 {call $foo 1}} 10]"