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

		<summary type="html">&lt;p&gt;13 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;got trouble to login Linix.&lt;br /&gt;
Used window MVS to develop program.&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/reference/clibrary/ctime/clock.html&lt;br /&gt;
&lt;br /&gt;
Some info about function &amp;quot;clock&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
CLOCKS_PER_SEC specifies the relation between a clock tick and a second (clock ticks per second).&lt;br /&gt;
&lt;br /&gt;
clock() return the current clock ticks but it is not a value of time.&lt;br /&gt;
&lt;br /&gt;
clock_t is variable defined in &amp;lt;ctime&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
        clock_t start_clock_t;&lt;br /&gt;
        clock_t end_clock_t;&lt;br /&gt;
        int n;&lt;br /&gt;
        int a;&lt;br /&gt;
        clock_t time_elapsed_t;&lt;br /&gt;
        start_clock_t=clock();&lt;br /&gt;
        for (n=0; n&amp;lt;100000000; n++)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
        end_clock_t=clock();&lt;br /&gt;
        time_elapsed_t =(end_clock_t - start_clock_t);&lt;br /&gt;
        printf (&amp;quot;%ld&amp;quot;,time_elapsed_t);&lt;br /&gt;
        return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
this is the code to test the clock ticks in the addition.&lt;br /&gt;
it is about 220.&lt;br /&gt;
&lt;br /&gt;
When we add an addition in the for lop.&lt;br /&gt;
  for (n=0; n&amp;lt;100000000; n++)&lt;br /&gt;
        {&lt;br /&gt;
        a++&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
clock ticks is not much different.&lt;br /&gt;
&lt;br /&gt;
When we change the variable to double.&lt;br /&gt;
&lt;br /&gt;
the clock ticks increase 4 times.&lt;br /&gt;
&lt;br /&gt;
The mean time usage in the for loops is comparing n and the end loop condition.&lt;br /&gt;
&lt;br /&gt;
i want the addition become a mean time usage in the for loop.&lt;br /&gt;
I try to decrease the comparing times.&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;time.h&amp;gt;&lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
        clock_t start_clock_t;&lt;br /&gt;
        clock_t end_clock_t;&lt;br /&gt;
        int n;&lt;br /&gt;
        int a;&lt;br /&gt;
        clock_t time_elapsed_t;&lt;br /&gt;
        start_clock_t=clock();&lt;br /&gt;
        a=0;&lt;br /&gt;
        for (n=0; n&amp;lt;10000000; n++)&lt;br /&gt;
        {&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
        a++;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
        end_clock_t=clock();&lt;br /&gt;
        time_elapsed_t =(end_clock_t - start_clock_t);&lt;br /&gt;
        printf (&amp;quot;%ld&amp;quot;,time_elapsed_t);&lt;br /&gt;
        return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
the clock ticks decrease to about 188.&lt;br /&gt;
In second version,5 times more addition command had been done.&lt;br /&gt;
&lt;br /&gt;
i guess the best way to test the time of addition is copy and paste 10000000 times &amp;quot;a++&amp;quot; in the main.c .&lt;br /&gt;
So pure machine code of addition can run for test.&lt;br /&gt;
And get the clock ticks number.&lt;br /&gt;
&lt;br /&gt;
The for loops include the compare command which makes the time measurement difficult.&lt;br /&gt;
I think i can&amp;#039;t get answer using for loops&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>