How can I improve performance? - 08.08.01

Julien SIMON

 

 

Here are a number of tips that help speed up execution:

  • Use arrayFillNonAtomic(), arrayCopy(), arrayCopyNonAtomic() to initialize/modify arrays. These are native methods, which are way faster than any clever Java code you could come up with.
  • In general, whenever the platform provides native code to perform an operation, use it!
  • Avoid EEPROM writes. Writing in EEPROM is about 1,000 times slower than writing in RAM, so the less you do it, the better. You'll save tens of milliseconds, if not hundreds. Believe us.
  • Use transient arrays to store session data and temporary results. Transient arrays are stored in RAM, so you'll avoid costly EEPROM writes.
  • Use the APDU buffer for cryptographic operations. Ditto: the APDU buffer is stored in RAM.
  • Avoid deep class trees: the deeper the tree, the slower the search for virtual methods. This can cost you several milliseconds on each method invocation…
  • Save array.length in a local variable before using it in a loop. If the loop is long enough, this will make a difference.
  • Do not use exceptions for flow control, only for error handling. Exception processing is very slow.

 

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact