Comments on: Introducing the SPEED? Function (PRELIMINARY)
REBOL Technologies

Comments on: Introducing the SPEED? Function (PRELIMINARY)

Carl Sassenrath, CTO
REBOL Technologies
16-Jan-2011 20:18 GMT

Article #0506
Main page || Index || Prior Article [0505] || Next Article [0507] || 7 Comments || Send feedback

Some of you know that there's a handy script on the REBOL website called speed.r. I use it quite often to get a general idea of the performance of various systems I work on.

For example, I'm writing this article from cheap Linux box that's not that fast. I can find out how well it runs REBOL with:

>> do
connecting to:
Script: "REBOL Quick and Dirty Speed Test" (none)

Console:   0:00:00.319016 - 1586 KC/S
Processor: 0:00:00.392543 - 2201 RHz (REBOL-Hertz)
Memory:    0:00:02.547215 - 18 MB/S
Disk/File: 0:00:00.762555 - 40 MB/S

BTW, an RHz ~= MHz. The scale difference in intentional. You know, "planning for future expansion."

So... this speed check isn't an advanced benchmark, but I've found it to be quite useful. Last summer I was working with someone on firing up a hosted virtual server. When I ran the speed.r test, I discovered that the disk/file test was only about 8 MB/S! (I've got 12 year-old 400 MHz PC's that run that fast.)

I contacted the ISP and after quite a lot of arm twisting I got them to measure the disk speed (using an independent method.) They were quite surprised how bad it was! We moved the server twice before landing on one that ran about 10 times faster... and, for the same price.

After that experience I decided to write speed? and make the speed test resident to all future R2 and R3 releases.

>> ? speed?
   SPEED? /no-io /times 

    Returns approximate speed benchmarks [eval cpu memory file-io].
    SPEED? is a function value.

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

The /no-io option is for when you're running from a mem-card (SD flash) or other device that you don't want to wear out.

The result is a block of numbers that you can easily format:

b: speed?
print [
   "evaluation:" b/1 lf
   "cpu:" b/2 lf
   "memory:" b/3 lf
   "file:" b/4

If you want to peek at the source (and it's pretty small), type:

source speed?

Note that it's not exactly the same as speed.r. I wanted to measure the interpreter's evaluation speed and CPU speed more independently. My goal was for those first two numbers to fall close to the MHz for your system, given adequate CPU caching with good DDR clocking (and of course, minimal task loading.)

Also note that this is just a preliminary version. If you have some improvements, let me know. But, also keep in mind, this is just a simple built-in test not used by most scripts, so it needs to stay quite small.



16-Jan-2011 23:49:19
Something seems to be wrong: in my copy of 2.7.8 for Windows, source speed? as well as probe second :speed? produce a very long output consisting of a repetition of the word test.
17-Jan-2011 0:37:44
The local variable tmp is not cleared after execution. So if you execute the speed? function then probe, source or ?? on speed? then it prints a very long output.

I also use this function to compare speed:

benchmark2: func [a b /local sa sb r ] [
    sa: now/precise loop 1000000 [do a] sa: difference now/precise sa
    sb: now/precise loop 1000000 [do b] sb: difference now/precise sb
    r: (to-decimal sa) / (to-decimal sb)
    print [
        "Execution time for #1 block:" sa newline
        "Execution time for #2 block:" sb newline
        either sa > sb [
            "#1 is slower than #2 by factor ~"
        ] [
            "#1 is faster than #2 by factor ~"
        either r > 1 [r] [1 / r]

>> benchmark2 [make block! 0] [copy []]
Execution time for #1 block: 0:00:00.359
Execution time for #2 block: 0:00:00.313
#1 is slower than #2 by factor ~ 1.14696485623003
== 1.14696485623003
Brian Hawley
17-Jan-2011 22:16:21
It's not tmp, which is recreated every time; it's the I/O buffer string, which should be.
Carl Sassenrath
30-Jan-2011 17:26:36
Right. The problem has been fixed in upcoming releases.
Gordon Raboud
12-May-2011 8:53:03
Very cool. Although the disk I/O on my machine seems too fast, probably because of caching someplace.
6-Jul-2011 9:07:38

[5804 0.172291 2539 1.036226 37 0.508451 216 0.140732] On my lenovo computer at work but under arch linux :P

Linux is what you need :P

more in details:

Console: 0:00:00.172291 - 5804 KC/S Processor: 0:00:01.036226 - 2539 RHz (REBOL-Hertz) Memory: 0:00:00.508451 - 37 MB/S Disk/File: 0:00:00.140732 - 216 MB/S

17-Jul-2012 3:29:08
It's not tmp, which is recreated every time; it's the I/O buffer string, which should web designing company

Post a Comment:

You can post a comment here. Keep it on-topic.


Blog id:



 Note: HTML tags allowed for: b i u li ol ul font p br pre tt blockquote

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 31-May-2023   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code