DHRYSTONE 2.1
=============

https://en.wikipedia.org/wiki/Dhrystone

Original Source Code:
http://www.roylongbottom.org.uk/classic_benchmarks.tar.gz

The base source code used for benchmarking is in this directory.

This is modified as little as possible to be compilable by the
compilers under test and that modified source code is present in
subdirectories.

CPU performance is measured in dhrystones/second which can be
computed from:

DHRYSTONES/S = Number_Of_Runs / Execution_Time

This figure was later reported in terms of performance against
a DEC VAX 11/780.  The VAX had a dhrystone score of 1757 so
this other performance figure called DMIPS is computed as follows:

DMIPS = (DHRYSTONES/S) / 1757

When compiling dhrystone 2.1, several defines are possible:

/*
 * COMMAND LINE DEFINES
 * These replace those discussed above but follow their intentions.
 * 
 * -DREGISTER
 * Corresponds to REG in description above.
 *
 * -DSTATIC
 * Makes REG variables static instead of register.  Overrides REGISTER.
 *
 * -DNOSTRUCTASSIGN
 * Use memcpy instead of struct assignment.
 * The stock SDCC copy still honors this. The z88dk classic and newlib
 * copies, and the HI-TECH v3.09 and v7.80 copies, always use struct
 * assignment.
 *
 * -DNOENUM
 * Use defines instead of enumeration.
 *
 * -DTIMER
 * Insert asm labels into source code at timing points (Z88DK).
 *
 * -DTIMEFUNC
 * Platform timer functions are available (must supply timer functions).
 *
 * -DPRINTF
 * Enable text output (Nunber_Of_Runs = 20000 if not enabled).
 *
 */

NOENUM can be defined freely depending on whether the compiler supports
enumerations. NOSTRUCTASSIGN is honored by the stock SDCC copy. The z88dk classic
and newlib copies, and the HI-TECH v3.09 and v7.80 copies, always use
struct assignment.

All compiles are first checked for correctness by running the program
with PRINTF defined.  After correctness is verified, time should be
measured with PRINTF undefined so that execution time of printf is not
measured.

REGISTER and STATIC can be defined if the compiler's performance can be
improved with these options enabled.

TIMEFUNC allows the host system's own clock to be used for timing so
that results can be printed out as part of the execution.  See source
code for details.

TIMER is defined for Z88DK compiles so that assembly labels are inserted
into the code at time begin and time stop points.

For a timed run, the program is compiled and simulated by TICKS.  TICKS
must be given a start address to start timing and a stop address to stop
timing.  In Z88DK compiles these show up in the map file.  Other compilers'
output may have to be disassembled to locate the correct address range.

The output of TICKS is a cycle count.  To convert to time in seconds:

Execution_Time = CYCLE_COUNT / FCPU
where FCPU = clock frequency of Z80 in Hz.

This time can be plugged into the dhrystone formulas above to compute
exact dhrystone performance.

(Number_Of_Runs = 20000 when PRINTF is disabled).


CLASSIC Z80 / 8085 SUMMARY
==========================

Timer-bounded classic +test. Full RESULT blocks: z88dk-classic/readme.txt.

Compiler | CPU  | Ticks
---------|------|------------
sccz80   | z80  | 473_021_519  (Nov 8, 2026)
sccz80   | 8085 | 385_680_196  (Nov 8, 2026)
80cc     | z80  | 284_380_153  (Nov 8, 2026)
80cc     | 8085 | 287_860_112  (Nov 8, 2026)
zsdcc    | z80  | 246_162_688  (Aug 16, 2026)


RESULTS
=======

1.
Z88DK August 16, 2026
classic/zsdcc 4.6.0 #16639
7852 bytes less page zero

cycle count  = 246162688
time @ 4MHz  = 246162688 / 4x10^6 = 61.54 seconds
dhrystones/s = 20000 / 61.54 = 324.9883
DMIPS        = 324.9883 / 1757 = 0.1850

2.
Z88DK August 16, 2026
zsdcc 4.6.0 #16639 / new c library
6982 bytes less page zero

cycle count  = 242442688
time @ 4MHz  = 242442688 / 4x10^6 = 60.61 seconds
dhrystones/s = 20000 / 60.61 = 329.9749
DMIPS        = 329.9749 / 1757 = 0.1878

3.
HITECH C MSDOS V780pl2
1895 bytes exact

cycle count  = 280100135
time @ 4MHz  = 280100135 / 4x10^6 = 70.0250 seconds
dhrystones/s = 20000 / 70.0250 = 285.6121
DMIPS        = 285.6121 / 1757 = 0.1625

4.
SDCC 4.6.0 #16608 Linux
6774 bytes less page zero

cycle count  = 274542684
time @ 4MHz  = 274542684 / 4x10^6 = 68.6357 seconds
dhrystones/s = 20000 / 68.6357 = 291.393
DMIPS        = 291.393 / 1757 = 0.16585

5.
IAR Z80 V4.06A
7371 bytes less small amount

cycle count  = 306860580
time @ 4MHz  = 306860580 / 4x10^6 = 76.7151 seconds
dhrystones/s = 20000 / 76.7151 = 260.7047
DMIPS        = 260.7047 / 1757 = 0.14838

6.
HITECH C CPM V309-15
8988 bytes exact

cycle count  = 356235065
time @ 4MHz  = 356235065 / 4*10^6 = 89.0588 sec
dhrystones/s = 20000 / 89.0588 = 224.5708
DMIPS        = 224.5708 / 1757 = 0.1278

7.
Z88DK November 8, 2026
sccz80 / classic c library
8366 bytes less page zero

cycle count  = 473021519
time @ 4MHz  = 473021519 / 4x10^6 = 118.26 seconds
dhrystones/s = 20000 / (473021519 / 4x10^6) = 169.1255
DMIPS        = 169.1255 / 1757 = 0.0963

8.
Z88DK November 8, 2026
sccz80 / classic c library / 8085
7972 bytes less page zero

cycle count  = 385680196
time @ 4MHz  = 385680196 / 4x10^6 = 96.42 seconds
dhrystones/s = 20000 / (385680196 / 4x10^6) = 207.4257
DMIPS        = 207.4257 / 1757 = 0.1181

9.
Z88DK November 8, 2026
80cc / classic c library
8159 bytes less page zero

cycle count  = 284380153
time @ 4MHz  = 284380153 / 4x10^6 = 71.10 seconds
dhrystones/s = 20000 / (284380153 / 4x10^6) = 281.3136
DMIPS        = 281.3136 / 1757 = 0.1601

10.
Z88DK November 8, 2026
80cc / classic c library / 8085
7802 bytes less page zero

cycle count  = 287860112
time @ 4MHz  = 287860112 / 4x10^6 = 71.97 seconds
dhrystones/s = 20000 / (287860112 / 4x10^6) = 277.9128
DMIPS        = 277.9128 / 1757 = 0.1582
