<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-3%3Amspe044</id>
	<title>SE250:lab-3:mspe044 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-3%3Amspe044"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:mspe044&amp;action=history"/>
	<updated>2026-04-28T17:26:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-3:mspe044&amp;diff=5630&amp;oldid=prev</id>
		<title>Mark: 5 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-3:mspe044&amp;diff=5630&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:22Z</updated>

		<summary type="html">&lt;p&gt;5 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Lab 3 (ArrayList Testing)&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Task One: When running an exp to find how long it takes to insert &amp;#039;n&amp;#039; elements into an ArrayList using &lt;br /&gt;
arraylist_push I used a 100 million for loop&lt;br /&gt;
&lt;br /&gt;
 clk1 = clock();&lt;br /&gt;
 &lt;br /&gt;
 for (count = 0; count &amp;lt; 100000000; count++) {&lt;br /&gt;
 arraylist_push(  &amp;amp;test_array, 5 );&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 clk2 = clock();&lt;br /&gt;
&lt;br /&gt;
This took 15292 microseconds to complete... I then removed the arraylist_push( &amp;amp;test_array, 5 ) code...&lt;br /&gt;
&lt;br /&gt;
 clk1 = clock();&lt;br /&gt;
 &lt;br /&gt;
 for (count = 0; count &amp;lt; 100000000; count++) {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 clk2 = clock();&lt;br /&gt;
&lt;br /&gt;
This took 288 microseconds to complete... therefore 100 million arraylist_push comands take ~15000&lt;br /&gt;
microseconds on the CS computer I used according to my testing.&lt;br /&gt;
 &lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Task Two: Test how changign the &amp;#039;* 2&amp;#039; in arraylist put effects the program. I initially tested with the origional&lt;br /&gt;
code on a &amp;#039;* 4&amp;#039; and a &amp;#039;* 10&amp;#039; value to get a feel for how it was effecting speeds and got this back.&lt;br /&gt;
&lt;br /&gt;
*2 = 15004&lt;br /&gt;
*4 = 15959&lt;br /&gt;
*10 = 14452...?!?&lt;br /&gt;
&lt;br /&gt;
Neadless to say I was a little confused so decided to re test and check my numbers between 2-10 this&lt;br /&gt;
time...&lt;br /&gt;
&lt;br /&gt;
2nd Test batch:&lt;br /&gt;
&lt;br /&gt;
*2 = 15291, 14975, 15835 (avrage = 15367)&lt;br /&gt;
*4 = 15795, 15581, 16279 (avrage = 15885)&lt;br /&gt;
*10 = 14372, 13901, 14105 (avrage = 14126)&lt;br /&gt;
&lt;br /&gt;
My results were reasionably consistant... to be honist I have no idea what it means besides the fact that&lt;br /&gt;
it shows that the efficency / growth facor has elements of an inverted prabola or some similer effect.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
Task Three: Significantly increase the value of ARRAYLIST MIN ALLOC... There is only one way to take this taks...&lt;br /&gt;
it says significantly so thats what I did, 10* and 100* arraylist min alloc...&lt;br /&gt;
&lt;br /&gt;
(16) Origional ARRAYLIST MIN ALLOC = 15367&lt;br /&gt;
(160) 10 * ARRAYLIST MIN ALLOC = 16516, 15787, 15843 (avrage = 16048)&lt;br /&gt;
(1600) 100 * ARRAYLIST MIN ALLOC = 14985, 15843, 14897 (avrage = 15242)&lt;br /&gt;
&lt;br /&gt;
Any difrences so far were insignificant... so I decided to REALY test wether it made a differece...&lt;br /&gt;
enter * 5,000&lt;br /&gt;
&lt;br /&gt;
(80000) 5,000 * ARRAYLIST MIN ALLOC = 16276 (single value)&lt;br /&gt;
(80000) 5,000,000 * ARRAYLIST MIN ALLOC = 15378 (single value)&lt;br /&gt;
&lt;br /&gt;
I gave in... guess it was a trick question.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Task Four: Call ensure capacity to pre-allocate the maximum expected size of the array arr, easy enough, just gave&lt;br /&gt;
the exact copacity 100000000, sat back and loged the result...&lt;br /&gt;
&lt;br /&gt;
12848, 12716, 12669 (avrage = 12744)&lt;br /&gt;
&lt;br /&gt;
Not bad if you ask me, a good 20% speed boos just from adding this&lt;br /&gt;
&lt;br /&gt;
ensure_capacity(&amp;amp;test_array, capacity);&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Task Five: Replace ARRAYLIST MIN ALLOC&amp;#039;s *2 value with a +1000 one. This made a HUGE difference to speed, with a&lt;br /&gt;
large value (my 100 million loop) it took a LONG time, after 5-6 minutes I gave in, with lower values&lt;br /&gt;
i.e. 100 thousand the speeds compared like this...&lt;br /&gt;
&lt;br /&gt;
+ 1000 = 23, 17, 15 (avrage = 18)&lt;br /&gt;
* 2 =  20, 15, 15 (avrage = 17)&lt;br /&gt;
&lt;br /&gt;
So + 1000 is alot less painful at lower array values that when making arrays of around 10 million cells&lt;br /&gt;
or more. Still, even though its closer to reachign the * 2 methods speed at no truly recordable value is&lt;br /&gt;
it better (speed wise).&lt;br /&gt;
&lt;br /&gt;
The moral of the story is for large arrays going + 1000 will absolutly hammer the speed it can have cells&lt;br /&gt;
added on at.&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Task Six: Use put rather than push function... with my 100 million cell array this took SO long I gave in, so I tryed&lt;br /&gt;
100 thousand cells (established avrage time for push at 100 thou is 17)&lt;br /&gt;
&lt;br /&gt;
Put times were... 4721, 4896, 4756 (avrage = 4791)&lt;br /&gt;
&lt;br /&gt;
The conclusion is im dam lucky I didnt wait long for my 100 million cell test... ANYHOW it would seem adding&lt;br /&gt;
memory onto the end is alot more plesent on the poor computer than shifting every value in the array along&lt;br /&gt;
one every single loop... no big suprise there though lol&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Armed with a few good questions on why incrasing *2 to *10 made no real difference when changing *2 to +1000 made such&lt;br /&gt;
a HUGE one at large array sizes (shouldnt it make SOME difference...?) and why ARAYLIST MIN ALLOC size changes made no&lt;br /&gt;
difference to speed I think ive learned alot in this one, one can hope anyhow...&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>