Posted to tcl by emiliano at Fri Feb 27 19:40:47 GMT 2009view raw

  1. emiliano@maq035:~$ cat withdict.tcl
  2. namespace eval foo {}
  3. for { set i 1 } { $i <= 100000 } { incr i } {
  4. dict set foo::mydict key_$i [string repeat A 1000]
  5. }
  6.  
  7. puts "Dict: [exec pmap [pid] | grep total]"
  8.  
  9. emiliano@maq035:~$ cat withonens.tcl
  10. namespace eval foo {}
  11. for { set i 1 } { $i <= 100000 } { incr i } {
  12. set foo::var_$i [string repeat A 1000]
  13. }
  14.  
  15. puts "Ns: [exec pmap [pid] | grep total]"
  16.  
  17. emiliano@maq035:~$ cat withmanyns.tcl
  18. for { set i 1 } { $i <= 100000 } { incr i } {
  19. namespace eval foo_$i {}
  20. set foo_${i}::var [string repeat A 1000]
  21. }
  22.  
  23. puts "One NS per var: [exec pmap [pid] | grep total]"
  24.  
  25. emiliano@maq035:~$ tclsh8.5 withdict.tcl ; tclsh8.5 withonens.tcl ; tclsh8.5 withmanyns.tcl
  26. Dict: total 125644K
  27. Ns: total 125644K
  28. One NS per var: total 158412K