1. Poking

I tested some routines to see which would be the best way to wipe/fill a
character buffer.
As you can see using repeat to generate a sequence, poking it into memory and
the repeated copying produces the fastest results.
My machine 486DX2/66MHz    tick_rate(100)

x 1000   * = 0.05 sec
------   ------------
0.050001 sec  *-->          s = repeat( c, 32 )    poke( a, s)    memcopy( s
    ) x 8
0.050001 sec  *-->          s = repeat( c, 64 )    poke( a, s)    memcopy( s
    ) x 4
0.060001 sec  *-->          s = repeat( c, 128 )    poke( a, s)    memcopy(
    s ) x 2
    0.130002 sec  ***-->        s = repeat( c, 256 )  poke( a, s)
    0.190003 sec  ****->        s = {c,c,c,c}  poke4( a, s ) x 64
    0.320005 sec  ******->      poke( a, c ) x 256
    0.470007 sec  *********->   poke4( a, {c,c,c,c} ) x 64

x 1000   * = 0.5 sec
------   -----------
0.240004 sec  -->           s = repeat( c, 320 )    poke( a, s)    memcopy(
    s ) x 8
0.360006 sec  *-->          s = repeat( c, 640 )    poke( a, s)    memcopy(
    s ) x 4
0.650010 sec  *-->          s = repeat( c, 1280 )    poke( a, s)    memcopy(
    s ) x 2
    1.180018 sec  **-->         s = repeat( c, 2560 )    poke( a, s)
    1.860029 sec  ****-->       s = {c,c,c,c}    poke4( a, s ) x 640
    3.160049 sec  ******-->     poke( a, c ) x 2560
    4.720073 sec  *********-->  poke4( a, {c,c,c,c} ) x 640

NOTE :
for 1000  aa = a   0.000000000000000 sec

-----< Code >-----
include machine.e
sequence s
integer c
atom addr, at, at_b
atom time_then, time_a, time_t

c = '3'
tick_rate(100)
addr = allocate( 2570 )
if addr then
    time_then = time()
        for t = 1 to 1000 do
            at = addr
        end for
    time_t = time() - time_then
    printf(1, "for 100  aa = a    %0.15f sec\n", time_t )

    time_then = time()
        for t = 1 to 1000 do
            at = addr
            at_b = addr
            s = repeat(c, 320 )
            poke( addr, s )
            for tt = 1 to 7 do
                at = at + 320
                mem_copy( at, at_b, 320 )
                at_b = at_b + 320
            end for
        end for
    time_a = time() - time_then - time_t
printf(1, "s = repeat( c, 320 )  poke( a, s)  memcopy( s ) x 8   
    %0.15f\n\n", time_a )

    free( addr )
end if
-----<End Code>-----

-----
Sincerely,
Mathew Hounsell
Mat.Hounsell at Mailexcite.Com

PS : Thak you Dave for the regular expression evaluator, and thank you Ralf for
the include info, you solved one of my most annoying problems.


Free web-based email, Forever, From anywhere!
http://www.mailexcite.com

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu