Page 1 of 1
Measure APDU time and memory
Posted: Mon May 29, 2017 3:58 pm
by Penneke
Hi,
Now I've developed and Applet in javacard with
JCIDE I want to know how much time (and memory if possible but less important) does it take an especific APDU to execute. I've been searching for a while without success. Is there any javacard code to measure time between 2 lines or does the debugger of
JCIDE has this option? If not, Is there any way better to do it than executing the same APDU in loop a lot of times and divide time taken by the number of times?
Thank's in advance.
Re: Measure APDU time and memory
Posted: Tue May 30, 2017 10:02 pm
by UNKNwYSHSA
Code: Select all
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}
byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x00:
short result = 0;
for (int i = 0; i < 500; ++i) {
}
apdu.setOutgoing();
apdu.setOutgoingLength((short) 2);
Util.setShort(buf, (short) 0, result);
apdu.sendBytes((short) 0, (short) 2);
break;
case (byte)0x01:
short result2 = 0;
for (int i = 0; i < 500; ++i) {
result2 += i;
}
apdu.setOutgoing();
apdu.setOutgoingLength((short) 2);
Util.setShort(buf, (short) 0, result2);
apdu.sendBytes((short) 0, (short) 2);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
Code: Select all
Download Cap begin...
Download Cap successful.
Install Applet begin...
Install Applet successful.
Select Applet begin...
Select Applet successful.
Send: 00 00 00 00 00
Recv: 00 00 90 00
Time used: 20.000 ms
Send: 00 01 00 00 00
Recv: E7 4E 90 00
Time used: 35.000 ms
Time spent by add instruction is about: (35 - 20) / 250.0 => 0.06ms
Re: Measure APDU time and memory
Posted: Sat Jun 03, 2017 2:28 pm
by Penneke
Sorry UNKNwYSHSA but I can see where you measure the time with
JCIDE. I took a picture running the code you provided so that you can check there is no time measure in the response. Can you tell me how I can make it to be displayed like you showed after the code?
Re: Measure APDU time and memory
Posted: Sun Jun 04, 2017 4:22 pm
by Penneke
Ok, now I see I can use the
pyApdutool together with
JCIDE to send APDU's and measure time there (have been using only the
JCIDE debugger command line). Thanks for ur help mate.