Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Just another dumb microbenchmark Vector vs. ArrayList  (Read 1081 times)
0 Members and 1 Guest are viewing this topic.
Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Posted 2005-08-11 01:17:48 »

If you think to hear something new ... don't wast your time reading this post ;-)

Just because I was interrested I tried the well-known ArrayLIst vs. Vector on a 4-way Power5 machine and it turned out that all the guys claming Vector is faster are fooled by the different resizing characteristics.
It did not more than adding 20.000.000 times the same string object to an initialized collection.

The Collections were created on own Thread so absolutly no contended locking:

Vector:
1 Thread:    2302ms/calculation
10 Threads 2151ms/calculation
50 Threads 2127ms/calc

ArrayList:
1 Thread:      2034ms/calc
10 Threads:  646ms/calc
50 Threads:  524ms/calc

as you can see, arraylist scales well with the number of processors, vector does not even scale a bit although no contended locks should appear. Another scaliability problem I found is Memory-Management which seems to scale not at all, too ... however the test was run on an IBM-JVM so I cannot speak about hotspots parallel GCs.

lg Clemens
Offline Orangy Tang

JGO Kernel


Medals: 48
Projects: 11


Monkey for a head


« Reply #1 - Posted 2005-08-11 01:26:37 »

Just because I was interrested I tried the well-known ArrayLIst vs. Vector on a 4-way Power5 machine and it turned out that all the guys claming Vector is faster are fooled by the different resizing characteristics.
Odd, I've never heard of Vector being suggested as faster than ArrayList. Given that ArrayList isn't syncronised it should be the faster one, where did you come across this particular snippit of 'wisdom'?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #2 - Posted 2005-08-29 20:41:43 »

Odd, I've never heard of Vector being suggested as faster than ArrayList. Given that ArrayList isn't syncronised it should be the faster one, where did you come across this particular snippit of 'wisdom'?

Well this is a quite general misunderstatement - since as far as I know ArrayList has different resizing charakteristis (more memory friedly).

Quote
My understanding of the history of Vector:
Vector was in the 1.0 libraries
By the time of 1.2 ArrayList had come along and people were switching to it for better performance. Vector was synchronised and because of that slower than the unsynchronised ArrayList.
By the time of 1.4 however the synchronisation mechanism was much much better - and Vector actually had a slight performance advantage over ArrayList.
If you're just repeating the old 1.2 mantra I recommend doing some performance testing with large Vectors and ArrayLists - and if you get roughly the same performance then you should switch to Vector because of its thread safety. (Advice I should take myself)

and of course many more unprofesisonal statements spread all over the web. However too tired fir searching them ;-)

lg Clemens
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (94 views)
2013-05-17 21:29:12

alaslipknot (102 views)
2013-05-16 21:24:48

gouessej (132 views)
2013-05-16 00:53:38

gouessej (127 views)
2013-05-16 00:17:58

theagentd (138 views)
2013-05-15 15:01:13

theagentd (126 views)
2013-05-15 15:00:54

StreetDoggy (167 views)
2013-05-14 15:56:26

kutucuk (189 views)
2013-05-12 17:10:36

kutucuk (192 views)
2013-05-12 15:36:09

UnluckyDevil (199 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.112 seconds with 20 queries.