13.8 Performance

The performance of gforth-fast is comparable to that of SwiftForth 4.0, while VFX Forth is faster by very roughly a factor of 2. For the benchmarks where a C version is available, gcc -O0 has a similar performance to gforth-fast. See Figure 1 of: M. Anton Ertl, Bernd Paysan, Code-Copying Compilation in Production — An Experience Report, EuroForth 2025 proceedings.

Below you see the performance of various Gforth engines with various options on a Ryzen 8700G (Zen4); the numbers are times in milliseconds, lower is better. First the progression of optimizations for gforth-fast shown in this chapter is measured, then gforth and gforth-itc:

sieve bubble matrix    fib    fft
145.5  163.3  114.1  166.4   79.6 gforth-fast --no-dynamic --ss-number=0
 54.0   61.8   32.4   49.2   18.1 gforth-fast --opt-ip-updates=0 --ss-states=1 --ss-number=0
 53.7   55.1   32.5   41.7   18.3 gforth-fast --opt-ip-updates=0 --ss-states=1
 53.4   59.5   31.8   42.7   14.7 gforth-fast --opt-ip-updates=0
 20.1   21.4   11.7   27.1   12.8 gforth-fast
 82.4  128.7   49.7  106.6   32.9 gforth
173.5  186.3  144.9  282.4   87.9 gforth-itc

gforth is slower by roughly a factor of 4 on the small benchmarks (where the IP-update optimization is particularly beneficial, so gforth’s performance may be closer to gforth-fast’s on application benchmarks). gforth-itc is slower than gforth by roughly another factor of 2.

You can measure your own machine with

taskset -c 1 sh -c '
 gforth-fast onebench.fs|grep sieve 
 for i in \
    "gforth-fast --no-dynamic --ss-number=0" \
    "gforth-fast --opt-ip-updates=0 --ss-states=1 --ss-number=0" \
    "gforth-fast --opt-ip-updates=0 --ss-states=1" \
    "gforth-fast --opt-ip-updates=0" \
    "gforth-fast" \
    "gforth" \
    "gforth-itc"
   do echo "`$i onebench.fs|grep -v sieve`" $i; done'

The taskset -c 1 limits the rest of the command to run on CPU (core) 1, so that you measure that core design (recent CPUs tend to have several different core designs) and to make sure that the core is revved up. Use different numbers to measure different cores. Leave the taskset -c 1 away if your OS does not support that command.

You can find numbers for gforth-fast onebench.fs on various machines in Benchres.