Attachment "match-bench.tcl" to
ticket [a4a7f2abd3]
added by
aku
2017-05-02 05:53:39.
#!/usr/bin/env tclsh
# https://research.swtch.com/glob
#
# ((a*)^n)b
# a^100
puts "Tcl [info patchlevel]"
set candidate [string repeat a 100]
for {set n 0} {$n < 7} {incr n} {
set pattern [string repeat a* $n]b
puts "[format %2d $n] = [time {string match $pattern $candidate}]"
}
# Results
##
# Tcl 8.5.14
# Tcl 8.6.1
##
# N microseconds
# - ------------
# 0 = 20
# 1 = 4
# 2 = 51
# 3 = 1,814
# 4 = 16,416
# 5 = 227,155 (0.2 seconds)
# 6 = 3,908,278 (3.9 seconds)
# 7 = 56,521,666 (56.5 seconds)
#
# TERMinated (via ^C)