Posted to tcl by sebres at Wed Jul 15 11:32:53 GMT 2020view raw

  1. proc test_fifo {l} { timerate {
  2. set l [linsert $l [set l 0] x]; set l [lreplace $l [set l 0] 0]
  3. } }
  4. proc test_lilo {l} { timerate {
  5. lappend l x; set l [lreplace $l [set l end] end]
  6. } }
  7.  
  8. set c 1000
  9. while {$c <= 1e6} {
  10. puts "** $c **"
  11. puts fifo:\t[test_fifo [lrepeat $c a]]
  12. puts lilo:\t[test_lilo [lrepeat $c a]]
  13. set c [expr {$c * 10}]
  14. }
  15.  
  16. # Results:
  17.  
  18. # ----------------------------------
  19. # Tcl 8.5:
  20. # ----------------------------------
  21.  
  22. # ** 1000 **
  23. # fifo: 0.815292 µs/# 1189045 # 1226554 #/sec 969.419 net-ms
  24. # lilo: 0.319608 µs/# 2895810 # 3128836 #/sec 925.523 net-ms
  25. # ** 10000 **
  26. # fifo: 4.296829 µs/# 231345 # 232729 #/sec 994.050 net-ms
  27. # lilo: 0.316483 µs/# 2922252 # 3159727 #/sec 924.843 net-ms
  28. # ** 100000 **
  29. # fifo: 44.1857 µs/# 22619 # 22631.7 #/sec 999.437 net-ms
  30. # lilo: 0.316588 µs/# 2921358 # 3158682 #/sec 924.866 net-ms
  31. # ** 1000000 **
  32. # fifo: 519.944 µs/# 1924 # 1923.3 #/sec 1000.373 net-ms
  33. # lilo: 0.317124 µs/# 2916790 # 3153344 #/sec 924.983 net-ms
  34.  
  35. # ----------------------------------
  36. # Tcl 8.6:
  37. # ----------------------------------
  38.  
  39. ** 1000 **
  40. fifo: 0.704807 µs/# 1338218 # 1418827 #/sec 943.186 net-ms
  41. lilo: 3.795696 µs/# 260543 # 263456 #/sec 988.942 net-ms
  42. ** 10000 **
  43. fifo: 4.236343 µs/# 233711 # 236052 #/sec 990.080 net-ms
  44. lilo: 35.7963 µs/# 27903 # 27935.9 #/sec 998.823 net-ms
  45. ** 100000 **
  46. fifo: 43.6455 µs/# 22890 # 22911.9 #/sec 999.046 net-ms
  47. lilo: 570.914 µs/# 1752 # 1751.6 #/sec 1000.241 net-ms
  48. ** 1000000 **
  49. fifo: 507.387 µs/# 1971 # 1970.9 #/sec 1000.059 net-ms
  50. lilo: 5640.94 µs/# 178 # 177.28 #/sec 1004.088 net-ms

Comments

Posted by sebres at Wed Jul 15 11:42:18 GMT 2020 [text] [code]

It looks like [lappend] is responsible for this performance degradation: - proc test_lilo {l} { timerate { lappend l x; set l [lreplace $l [set l end] end] } } + proc test_lilo {l} { timerate { set l [linsert $l [set l end] x]; set l [lreplace $l [set l end] end] } } solves that for 8.6. WiP.