Skip to content
Tcl Source Code Changes To Faster UTF encoding
Login

Changes To Faster UTF encoding

Changes to "Faster UTF encoding" between 2026-02-25 07:57:24 and 2026-02-25 07:58:38

︙
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
25
26
27
28
29
30
31

32
33
34
35
36
37
38

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62







-
+






-
+















-
+







On the flip side, for pathological cases timings are increased by 11-25% depending
on the language and operation.

**Given that the pathological cases are very unlikely to occur in practice and the
marked improvements for the likely statistical distribution of characters, it is
proposed that the changes be adopted.**

**Benchmarks**
### Benchmarks

The I/O benchmarks reflect only the time for encoding, not Tcl command, channel overhead
etc.

(times in microseconds)

[apn-utf-fastpath](https://core.tcl-lang.org/tcl/timeline?r=apn-utf-fastpath) branch...
#### [apn-utf-fastpath](https://core.tcl-lang.org/tcl/timeline?r=apn-utf-fastpath) branch...

```
c:\src\tcltk\wip\tcl\win>Release_AMD64_VC1944\tcltest91.exe utfbench.tcl 10000
Calibrating...0.03633541899879032 µs/#-overhead 0.037819 µs/# 51613951 # 26441573 #/sec

                                      convertto  convertfrom         puts         read
 ascii (10000)                            6.721        6.587        6.055        6.881
 western (10000)                         13.247       13.323       12.536       13.921
 cyrillic (10000)                        65.343       70.621       63.727       72.637
 eastern (10000)                         81.155       88.541       79.834       91.147
 western - pathological (10000)          60.158       61.249       59.822       62.990
 cyrillic - pathological (10000)         59.327       60.862       57.919       66.279
 eastern - pathological (10000)          64.834       67.425       63.501       69.091
```

Compare with current trunk...
#### Current trunk

```
c:\src\tcltk\main\tcl\win>Release_AMD64_VC1944\tcltest91.exe ..\..\..\wip\tcl\win\utfbench.tcl 10000
Calibrating...0.0345694057395217 µs/#-overhead 0.035182 µs/# 55482315 # 28423317 #/sec

                                      convertto  convertfrom         puts         read
 ascii (10000)                           22.834       22.802       22.279       23.333
︙