SE250:lab-1:aomr001
the aim of this lab was to measure the time taken to do an addition operation .
i have decided to do this by doing a for loop for a million operations , by adding 2 integer numbers together for a million times. to measure the time take i have used the clock function before starting the for loop and after the for loop, then taking the time difference to measure how long it took to do the opertaions.
for (i=0; i < 10000; i++){ j = 1 + 1; }
the time taken was 2 ms when using 2 integer numbers. i have tried to use different variable types and found out that they vary in time taken to do these addition opertations. for example: adding 2 double number .. took more time to do.. it took about 9 ms to carry out.
i have also noticed that when i have removed the for loop and replaced it with a million operation manually .. the operation took even longer time to do ..!
another thing that could be mentioned is that almost everytime i tried to run the code to measure how long it takes to do the operation i had different results, although i was using the same machine, which suggests that the same machine could possibly carry out operations differently each time ..
difficulties: -the main difficulties that i faced were with the syntax. it has been a long time since i last used c to program .. which meant that i couldn't remmber most of the codes used. i had to get help from my mates a couple of times regarding the syntax. - it was the first time that i have actually used the clock function.. it took me some time to figure out what it actually does.
the task was reasonably easy to attempt.
Aomr001 11:56, 4 March 2008 (NZDT)