<?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-1%3Ajpar277</id>
	<title>SE250:lab-1:jpar277 - 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-1%3Ajpar277"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:jpar277&amp;action=history"/>
	<updated>2026-04-28T21:19:48Z</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-1:jpar277&amp;diff=4348&amp;oldid=prev</id>
		<title>Mark: 10 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-1:jpar277&amp;diff=4348&amp;oldid=prev"/>
		<updated>2008-11-03T05:18:42Z</updated>

		<summary type="html">&lt;p&gt;10 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Hi all!&lt;br /&gt;
&lt;br /&gt;
Well first I thought I&amp;#039;d start by discussing the code I used.&lt;br /&gt;
The lab handout did state that we might not have done any coding in the last 3 months and that would be very correct in my case! lol&lt;br /&gt;
So I had to go a review a few bits of code from last years 131 course (thank god I had my usb with me)&lt;br /&gt;
&lt;br /&gt;
Then I needed some assistance with the clock function. I turned to the help menu for this rather than asking the tutors.&lt;br /&gt;
And I came across a very interesting piece which described exactly what we were doing!&lt;br /&gt;
&lt;br /&gt;
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vccrt/html/3e1853dd-498f-49ba-b06a-f2315f20904e.htm&lt;br /&gt;
&lt;br /&gt;
^^^ url must be inserted in the help menu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The code I ended up using was ::::&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;time.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main(void) {&lt;br /&gt;
 	long input = 4000000;&lt;br /&gt;
 	long i = 0;&lt;br /&gt;
 	double  duration;&lt;br /&gt;
 &lt;br /&gt;
 	clock_t start, finish;&lt;br /&gt;
 &lt;br /&gt;
 	start = clock();&lt;br /&gt;
 	while(i &amp;lt; input) &lt;br /&gt;
 		i++;&lt;br /&gt;
 	finish = clock();&lt;br /&gt;
 &lt;br /&gt;
 	duration = (double)(finish - start) / CLOCKS_PER_SEC;&lt;br /&gt;
 &lt;br /&gt;
 	printf(&amp;quot;Time taken to add 1 up to %d is %f seconds\n&amp;quot;, input, duration);&lt;br /&gt;
 &lt;br /&gt;
 	return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
I started at an input of 1000000 (1million) and worked my way up to 10000000 (10million) in intervals of 100000 (100thousand).&lt;br /&gt;
As you&amp;#039;d expect the seconds increased with each extra addition of 100000, however my results were only accurate to the nearest millisecond so the increase in time wasn&amp;#039;t very exact. I got an increase in time by 1 millisecond every 4-6 increase in 100000.&lt;br /&gt;
&lt;br /&gt;
Something interesting I noticed was that when the number of additions was doubled, the time was longer than double!&lt;br /&gt;
&lt;br /&gt;
1000000 = 0.002s&lt;br /&gt;
&lt;br /&gt;
2000000 = 0.005s !!&lt;br /&gt;
&lt;br /&gt;
and the pattern continued higher up additions.&lt;br /&gt;
&lt;br /&gt;
You may have noticed how my code example contains longs, I tried int only to find I get the same results. Short couldn&amp;#039;t be carried out as the number of additions was too little, I couldn&amp;#039;t go beyond 2304. I had issues with float and double, it just wouldn&amp;#039;t work :S&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Here are my full results that I recorded ::::&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
1000000 = 0.002s&lt;br /&gt;
&lt;br /&gt;
1100000 = 0.003s&lt;br /&gt;
&lt;br /&gt;
1200000 = 0.003s&lt;br /&gt;
&lt;br /&gt;
1300000 = 0.003s&lt;br /&gt;
&lt;br /&gt;
1400000 = 0.003s&lt;br /&gt;
&lt;br /&gt;
1500000 = 0.004s&lt;br /&gt;
&lt;br /&gt;
1600000 = 0.004s&lt;br /&gt;
&lt;br /&gt;
1700000 = 0.004s&lt;br /&gt;
&lt;br /&gt;
1800000 = 0.004s&lt;br /&gt;
&lt;br /&gt;
1900000 = 0.004s&lt;br /&gt;
&lt;br /&gt;
2000000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2100000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2200000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2300000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2400000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2500000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2600000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2700000 = 0.005s&lt;br /&gt;
&lt;br /&gt;
2800000 = 0.006s&lt;br /&gt;
&lt;br /&gt;
2900000 = 0.006s&lt;br /&gt;
&lt;br /&gt;
3000000 = 0.007s&lt;br /&gt;
&lt;br /&gt;
3100000 = 0.007s&lt;br /&gt;
&lt;br /&gt;
3200000 = 0.007s&lt;br /&gt;
&lt;br /&gt;
3300000 = 0.007s&lt;br /&gt;
&lt;br /&gt;
3400000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
3500000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
3600000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
3700000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
3800000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
3900000 = 0.008s&lt;br /&gt;
&lt;br /&gt;
4000000 = 0.009s&lt;br /&gt;
&lt;br /&gt;
4500000 = 0.010s&lt;br /&gt;
&lt;br /&gt;
5000000 = 0.011s&lt;br /&gt;
&lt;br /&gt;
5500000 = 0.012s&lt;br /&gt;
&lt;br /&gt;
6000000 = 0.013s&lt;br /&gt;
&lt;br /&gt;
6500000 = 0.014s&lt;br /&gt;
&lt;br /&gt;
7000000 = 0.016s&lt;br /&gt;
&lt;br /&gt;
7500000 = 0.017s&lt;br /&gt;
&lt;br /&gt;
8000000 = 0.018s&lt;br /&gt;
&lt;br /&gt;
8500000 = 0.019s&lt;br /&gt;
&lt;br /&gt;
9000000 = 0.020s&lt;br /&gt;
&lt;br /&gt;
9500000 = 0.021s&lt;br /&gt;
&lt;br /&gt;
9600000 = 0.021s&lt;br /&gt;
&lt;br /&gt;
9700000 = 0.021s&lt;br /&gt;
&lt;br /&gt;
9800000 = 0.022s&lt;br /&gt;
&lt;br /&gt;
9900000 = 0.022s&lt;br /&gt;
&lt;br /&gt;
10000000 = 0.022s&lt;br /&gt;
&lt;br /&gt;
It took some time remembering bits of code but in the end I think I got some standard results.&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>