Reputation: 167
i'm new to java card technology, and i'm also unaware what is normal execution time on java card. I know it will be slow on java card, and because of it should only deal with simple stuff.
Although i acknowledge that, i came to really odd figure of execution time of a simple piece of code, the code below takes exactly 1300 ms to run, is it normal?
I'm executing this in a smartc@fe card 3.2 that has 13 Mhz of processor, and less than 2KB RAM and 72KB of EEPROM.
If possible could you also test this with the card available to you? if so, please respond and with the specification of the card.
private static short benchmark()
{
short v, n, x, y;
short x_size, y_size;
v = 0;
n = 128;
x_size = 100;
y_size = 100;
for (x = 0; x < x_size; x++)
for (y = 0; y < y_size; y++)
v = (short) ~((v + n) & 0xFF);
return v;
}
Upvotes: 1
Views: 271
Reputation: 178
I ran it on a JCOP 2.4.1 card and I got 650ms of card processing time. Either OS or hardware on your card are slow.
One idea to make it faster is to use one for loop instead of two loops, since you do not make use of x and y.
Also you could replace v = (short) ~((v + n) & 0xFF);
with
v = (short) ~((v + (short)128) & 0xFF);
because n is constant and the resulting bytecode will be smaller.
Upvotes: 0
Reputation: 2647
It takes me 731 ms on some pretty new JCOP cards to run your code, so this seems valid
Upvotes: 2