News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

A test piece showing how to accurately benchmark algorithms

Started by hutch--, March 19, 2023, 08:12:59 AM

Previous topic - Next topic

hutch--

Some time ago I posted an example in the PB forum about how and why you sometimes deviate from modular programming when writing an assembler algorith. The example was a "text cleanup" algorithm that for efficiency and speed reasons bundled a number of capacities into the algorithm.

It was originally written in about 2008 and has since been replaced with a multiline version as this original was directly aimed at single line targets but its main virtue was that it was still a reasonably simple algorithm that served as an example of multiple functions to avoid overhead.

Unfortunately a regular contributor in the PB forum did his best to take over the topic and turn it into some form of competition against a test piece posted for an entirely different purpose.

Here is the algo timing using a method that produces extremely narrow deviation on multiple runs, not the amateurish deviation of over 100% by people who try and use the "TIX" method.

It should be noted that the founder of PowerBASIC, Bob Zale, was a member of the MASM forum until he passed away in 2012, a highly gifted assembler programmer who not only designed and built the PowerBASIC languages but designed into them a very competent inline assembler that was available to use for specialised algorithms.

This is the output of the benchmark on my old i7.

Original text to repair
        Rough text,       badly spaced and full            of    junk

Assembler Version correctness test
Rough text, badly spaced and full of junk

High level Version correctness test
Rough text, badly spaced and full of junk

Timing = 1594 ms Assembler Version
Timing = 2297 ms High Level Version
Timing = 1594 ms Assembler Version
Timing = 2282 ms High Level Version
Timing = 1594 ms Assembler Version
Timing = 2282 ms High Level Version
Timing = 1610 ms Assembler Version
Timing = 2281 ms High Level Version
Timing = 1594 ms Assembler Version
Timing = 2297 ms High Level Version
Timing = 1609 ms Assembler Version
Timing = 2266 ms High Level Version
Timing = 1594 ms Assembler Version
Timing = 2282 ms High Level Version
Timing = 1578 ms Assembler Version
Timing = 2281 ms High Level Version

Average timing asm Version = 1595 ms
Average high level Version = 2283 ms

Thats all folks