Maybe, someone finds this information useful:
i did a quick comparison of the various options for base64
codecs. It shows that NaviServer's built-in ns_base64encode is very fast: it is up to a factor of 1.000 faster than the Tcl-only version of base64::encode, and even a factor of 10 faster than base64::encode based on Trf (Trf 2.1.4). While a big difference relative to the plain Tcl version
is expected, the improvement over the C-based Trf
is remarkable.
The results are measured with the latest version of NaviServer from bitbucket under Mac OS X 10.9.5.
Using ns_base64encode reduces the external dependencies
and is by far the fastest version.
all the best
-g
size=100
tcllib: 134.713824 microseconds
tcllib+trf: 4.561536 microseconds
ns: 0.541651 microseconds
size=1000
tcllib: 1281.819696 microseconds
tcllib+trf: 16.93683 microseconds
ns: 1.517516 microseconds
size=10000
tcllib: 12638.85578 microseconds
tcllib+trf: 143.11120 microseconds
ns: 11.08016 microseconds
size=100000
tcllib: 127344.794553 microseconds
tcllib+trf: 1423.021879 microseconds
ns: 113.504248 microseconds
------
foreach i {10 100 1000 10000} {
set s [string repeat 0123456789 $i]
lappend _ size=[string length $s]
lappend _ tcllib:[time {base64::encode $s} 1000]
lappend _ ns:[time {ns_base64encode $s} 1000]
}
join $_ \n