Shop OBEX P1 Docs P2 Docs Learn Events
instructions per second? — Parallax Forums

instructions per second?

Scott MScott M Posts: 43
edited 2005-04-20 17:38 in General Discussion
Does anyone have information that shows how many VM operations the Javelin can do per second - or better yet, the execution time for each opcode? I know that a line of Java doesn't translate to a single opcode, but I'm prepared to disassemble the compiled output. I'm trying to find out exactly how much I can get away with in a 1/10th of a second. Thanks.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-04-12 18:59
    I have no opcode speeds, but to give an impression:

    In a tight for-next loop you can read about a 1000 bytes per second

    from a character array, so in 0.1 second you can read about 100 bytes.

    That is with no operations applied to the bytes.

    int i;
    char x;
    char[noparse]/noparse buf = new char[noparse][[/noparse]10000];

    for (i=0; i<10000;; i++) {
    · x = buf[noparse][[/noparse]i];
    }

    regards peter
    ·
  • Scott MScott M Posts: 43
    edited 2005-04-20 14:38
    Peter Verkaik said...

    I have no opcode speeds, but to give an impression:

    In a tight for-next loop you can read about a 1000 bytes per second

    from a character array, so in 0.1 second you can read about 100 bytes.

    That is with no operations applied to the bytes.

    int i;
    char x;
    char[noparse]/noparse buf = new char[noparse][[/noparse]10000];

    for (i=0; i<10000;; i++) {
    · x = buf[noparse][[/noparse]i];
    }

    regards peter

    This explains much. I'd been wondering why my app seemed to take so long to do serial output on a small handful of bytes. But that small handful of bytes has to be copied before they can be sent, and, if copying 100 bytes takes 0.1 secs, that's the time budget right there.



    It would be a help, I think, if we had a native method for

    ·· serout.sendBytes(char[noparse]/noparse data, int startingOffsetInArray, int numberToSend)

    to go with serout.sendString(String s);

    It's very natural to create an array (often a circular buffer) of things you want to send; not so natural to manipulate Strings to get the same sort of effect. But creating an array inevitably means some code like

    ··· serout.sendByte(data[noparse][[/noparse]i]); //for lots of values of i

    and that, clearly, is very, very·slow...
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-04-20 17:38
    Get my adapted uart class here, first rename your original uart.java to uart.org
    http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/core/

    In this class the buffer is defined as a public char array, which means you can fill
    up that buffer directly from your code, and only after·you set head (so·head != tail) the uart VP
    starts transmitting. Alone the fact that it is a char array alaready speeds up
    throughput. If you store·your output data directly in the transfer buffer
    instead of your own array first, throughput is even better.

    regards peter

    PS: that class supports parity. If you remove the parity support the read and write methods
    get even tighter.

    ·
Sign In or Register to comment.