Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

Measure APDU time and memory

JavaCard Applet Development Related Questions and Answers.
Penneke
Posts: 10
Joined: Tue Mar 21, 2017 8:26 pm
Points :160
Contact:

Measure APDU time and memory

Post by Penneke » Mon May 29, 2017 3:58 pm

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.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: Measure APDU time and memory

Post by UNKNwYSHSA » Tue May 30, 2017 10:02 pm

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
sense and simplicity

Penneke
Posts: 10
Joined: Tue Mar 21, 2017 8:26 pm
Points :160
Contact:

Re: Measure APDU time and memory

Post by Penneke » Sat Jun 03, 2017 2:28 pm

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?
You do not have the required permissions to view the files attached to this post. Please login first.

Penneke
Posts: 10
Joined: Tue Mar 21, 2017 8:26 pm
Points :160
Contact:

Re: Measure APDU time and memory

Post by Penneke » Sun Jun 04, 2017 4:22 pm

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.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Google [Bot] and 72 guests

JavaCard OS : Disclaimer