• Re: May the numbers speak

    From sean@conman.org@21:1/5 to It was thus on Thu Jun 12 05:07:54 2025
    It was thus said that the Great Hans Bezemer <the.beez.speaks@gmail.com> once stated:

    It's slightly faster than the original on 4tH:
    real 0m5,527s
    user 0m5,522s
    sys 0m0,004s

    Opcodes: his: 39, yours: 37

    I think I am in a unique position to get an exact cycle count of the
    various attempts due to cycle emulation of the CPU my ANS Forth implemention targets (the 6809, an 8-bit CPU). I ran the three versions LIT presented,
    plus the version he said was Mr. Fifo's. I also ran dxf's version. Each version included the following word:

    : FOO S" 12:34:56" TIMESTRSCAN D. ;

    and I recorded the number CPU cycles the following line took to run:

    FOO BYE

    The results:

    dxf cycles=75453
    fifo cycles=85658
    LIT#1 cycles=78642
    LIT#2 cycles=78714
    LIT#3 cycles=78720

    I also ran miniforth's version, and timed this the line:

    HMS 12:34:56 .S BYE

    It was not fast:

    minforth cycles=834951

    Make of this what you will.

    -spc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Thu Jun 12 08:12:50 2025
    There may be several issues on a real computer which make
    these considerations immaterial:

    ANEW -timescan

    : dtimescan ( addr count -- d )
    over swap + >r >r
    0. r> 0
    begin
    over r@ <
    while
    over c@ ':'
    = if swap >r s>d d+ #60 1 m*/ r> 0
    else #10 * over c@ [char] 0 - +
    endif
    swap 1+ swap
    repeat
    -r nip s>d d+ ;

    : timestrscan ( addr count -- d )
    1 1 LOCALS| c6 c1 |
    0. 2SWAP
    OVER + 1- ?DO
    I C@ DUP ':' =
    IF DROP
    c6 #60 * TO c6
    1 TO C1
    ELSE '0' - C1 * C6 M* D+
    #10 TO C1
    ENDIF
    -1 +LOOP ;

    : TEST ( -- )
    CR ." \ dtimescan : " S" 12:34:56" TICKS-RESET dtimescan
    TICKS? UD. ." clock ticks elapsed, " UD.
    CR ." \ timestrscan : " S" 12:34:56" TICKS-RESET timestrscan
    TICKS? UD. ." clock ticks elapsed, " UD. ;

    TEST

    FORTH> in
    \ dtimescan : 1258 clock ticks elapsed, 45296
    \ timestrscan : 419 clock ticks elapsed, 45296 ok
    FORTH> TEST TEST TEST
    \ dtimescan : 1258 clock ticks elapsed, 45296
    \ timestrscan : 419 clock ticks elapsed, 45296
    \ dtimescan : 419 clock ticks elapsed, 45296
    \ timestrscan : 420 clock ticks elapsed, 45296
    \ dtimescan : 419 clock ticks elapsed, 45296
    \ timestrscan : 420 clock ticks elapsed, 45296
    FORTH>

    A 'clock tick' is approximately 0.2ns.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to sean@conman.org on Thu Jun 12 08:13:01 2025
    On Thu, 12 Jun 2025 5:07:54 +0000, sean@conman.org wrote:
    I also ran miniforth's version, and timed this the line:

    HMS 12:34:56 .S BYE

    It was not fast:

    minforth cycles=834951

    Make of this what you will.

    But software development time about 1 minute including
    typing. :o) And no bugs in the first trial run.

    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)