USAGE: edit

SPEED? /no-io /times 

DESCRIPTION: edit

Returns approximate speed benchmarks [eval cpu memory file-io].

SPEED? is a function value.

REFINEMENTS edit

  • /no-io -- Skip the I/O test
  • /times -- Show time for each test

SOURCE CODE edit

speed?: func [
    {Returns approximate speed benchmarks [eval cpu memory file-io].} 
    /no-io "Skip the I/O test" 
    /times "Show time for each test" /local 
    result 
    x 
    calc 
    tmp file 
    secs
][
    result: copy [] 
    foreach block [
        [
            loop 100000 [
                x: 1 * index? back next "x" 
                x: 1 * index? back next "x" 
                x: 1 * index? back next "x" 
                x: 1 * index? back next "x"
            ] 
            calc: [100000 / secs / 100]
        ] [
            tmp: make binary! 500000 
            insert/dup tmp "abcdefghij" 50000 
            loop 10 [
                random tmp 
                decompress compress tmp
            ] 
            calc: [(length? tmp) * 10 / secs / 1900]
        ] [
            repeat n 40 [
                change/dup tmp to-char n 500000
            ] 
            calc: [(length? tmp) * 40 / secs / 1024 / 1024]
        ] [
            unless no-io [
                write file: %tmp-junk.txt "" 
                tmp: head insert/dup "" "test^/" 32000 
                loop 100 [
                    write/binary file tmp 
                    read/binary file
                ] 
                delete file 
                calc: [(length? tmp) * 100 * 2 / secs / 1024 / 1024]
            ]
        ]
    ] [
        secs: now/precise 
        calc: 0 
        recycle 
        do block 
        secs: to decimal! difference now/precise secs 
        append result to integer! do calc 
        if times [append result secs]
    ] 
    result
]