Академический Документы
Профессиональный Документы
Культура Документы
Real-Time and
High-Performance
Applications
July 4, 2005
Jean-Marie Dautelle
Introduction
The real-time specification for Java (RTSJ) aims to make
your code more time predictable. But, this predictability can
easily be ruined by using standard library classes. In this
presentation we will look at potential problems with the
standard Java collection framework and how these problems
can be solved by using alternative implementations such as
the one provided by the open-source Javolution library
(http://javolution.org)
Standard Collections Overview
• Interface based.
• java.util.List
• java.util.Map
• java.util.Set
• ...
• Interface approach allow for “drop-in” replacement.
• Generic since Java™ 5.0
• Oriented toward throughput
• Time predictability and RTSJ (Real Time
Specification for Java ) not taken into consideration
by the implementation.
Standard Collections Timing Issues
◗ Users may encounter unexpected large delays due to:
70
60 FastTable (new)
50 FastTable (recycled)
Nano-Seconds
ArrayList (new)
40 ArrayList (recycled)
30 FastList (new)
FastList (recycled)
20 LinkedList (new)
10 LinkedList (recycled)
0
1 2 3 4
Log10(Size)
List – Iteration Performance
List - Iteration
40
FastTable - Iterator
35
30 FastTable - get(i++)
Nano-Seconds
25 ArrayList - Iterator
20
ArrayList - get(i++)
15
10 FastList - Iterator
5
FastList -
0 getNextNode()
1 2 3 4 LinkedList - Iterator
Log10(Size)
Map - Put Performance
Map - put
250
FastMap (new)
200
Nano-Seconds
FastMap (recycled)
150
HashMap (new)
100
HashMap (recycled)
50
LinkedHashMap (new)
0 LinkedHashMap
1 2 3 4 (recycled)
Log10(Size)
Map – Iteration Performance
Map - Iteration
50
45
40 FastMap - Iterator
35
Nano-Seconds
30 FastMap -
getNextEntry()
25
HashMap - Iterator
20
15 LinkedHashMap -
10 Iterator
5
0
1 2 3 4
Log10(Size)
Map – Get Performance
Map - get
60
50
Nano-Seconds
40
FastMap
30 HashMap
LinkedHashMap
20
10
0
1 2 3 4
Log10(Size)
Set – Add Performance
Set - Add
250
FastSet (new)
200
Nano-Seconds
FastSet (recycled)
150
HashSet (new)
100
HashSet (recycled)
50
LinkedHashSet (new)
0 LinkedHashSet
1 2 3 4 (recycled)
Log10(Size)
Set – Iteration Performance
Set - Iteration
60
50
FastSet - Iterator
Nano-Seconds
40
FastSet -
getNextRecord()
30
HashSet - Iterator
20
LinkedHashSet -
Iterator
10
0
1 2 3 4
Log10(Size)
Set – Contains Performance
Set - Contains
50
45
40
35
Nano-Seconds
30 FastSet
25 HashSet
20 LinkedHashSet
15
10
5
0
1 2 3 4
Log10(Size)