It's UWAweek 48

help2003/help4407

This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 11 articles in this topic
Showing 11 of 564 articles.
Currently 3 other people reading this forum.


 UWA week 16 (1st semester, non-teaching week) ↓
SVG not supported

Login to reply

👍?
helpful
6:15am Tue 19th Apr, ANONYMOUS

With regards to assignment 1, will we be penalised if our programs take too long to run? Currently, my malaria_incidence takes ~20 seconds to run (due to a for loop).


SVG not supported

Login to reply

👍?
helpful
8:26am Tue 19th Apr, Daniel S.

Long runtimes may cause you to lose marks for style/maintainability, because it indicates that you have inefficiencies in your code (such as many nested loops). Bash isn't super efficient anyway, so if it takes a few seconds to execute (especially on large files), that's fine. Once you get above 10 seconds I'd probably be concerned, unless the input file is truly colossal. If your script takes over a minute then that's a real problem.


SVG not supported

Login to reply

👍?
helpful
5:36pm Tue 19th Apr, Bryan C.
Edited: shortly thereafter

That's surprising, because I did not nest any for loops, I simply step through each row in the csv file once and i'm taking 20-30 seconds. Is a file size of 2033 lines considered "colossal" or should I be concerned?


SVG not supported

Login to reply

👍?
helpful
5:36pm Tue 19th Apr, ANONYMOUS

That's surprising, because I did not nest any for loops, I simply iterate over each row of the csv file once and i'm taking 20-30 seconds. Is a file size of 2033 lines considered "colossal" or should I be concerned?


SVG not supported

Login to reply

👍?
helpful
6:43pm Tue 19th Apr, Ryan B.

ANONYMOUS wrote:
> That's surprising, because I did not nest any for loops, I simply iterate over each row of the csv file once and i'm taking 20-30 seconds. Is a file size of 2033 lines considered "colossal" or should I be concerned?
To answer the second question, first: 2033 is quite small. For example, the Alice in Wonderland file we have been working with in the labs is almost 4000 lines, and all our scripts take very little time to complete. What I suspect you are doing is redundant operations; by this, I mean doing unnecessary processing for every line first. If I am passing in a country as an argument, for example, I should only be concerned with doing further 'searching/sorting' on the subset of data to do with that country (max 10-15 lines/country). I suspect you may be doing all the computation for each country upfront by check if each row is the right country, and then compare the number in that row to a `max` variable somewhere? I could be wrong, this is a pure guess. At any rate, a line-by-line approach is probably unnecessary for this particular question. I'd recommend taking a step back, and perhaps looking over some of the more recent material on regular expressions with `grep` and `sed`. Remember that we have been processing multiple rows in a csv file in various ways (using `sort`, `cut` etc.) without having to loop through them line-by-line in the labs, so perhaps review that material, too. Hope this helps! Ryan (lab guy).


SVG not supported

Login to reply

👍?
helpful
6:51pm Tue 19th Apr, Michael W.

ANONYMOUS wrote:
> That's surprising, because I did not nest any for loops, I simply iterate over each row of the csv file once and i'm taking 20-30 seconds. Is a file size of 2033 lines considered "colossal" or should I be concerned?
Hi, Greetings from Kalgoorlie. That is surprising. To inject a little precision into the discussin <grin> you can use the built-in Bash command time, to account for how much time a command actually takes. On my mid 2016 MacBook Pro, % time malaria_incidence 2004 For the year 2004, the country with the highest incidence was Solomon Islands, with a rate of 744 per 1,000 real 0m0.024s user 0m0.009s sys 0m0.015s So yes, if mine takes 0.024 seconds and yours takes ~20 seconds (making huge assumptions about comparable machines), then there may be a problem with efficiency that you care to look into. However, first things first: get something that works for both Parts of the assignment. Then improve them. Cheers MichaelW


SVG not supported

Login to reply

👍?
helpful
3:50pm Wed 20th Apr, ANONYMOUS

Just to clarify, does 20 seconds mean 0m20.***s as in the output or 0m0.020s? Since so far my code is functioning correctly but it takes around 0m0.060s. Would I be penalised in this case?


SVG not supported

Login to reply

👍?
helpful
3:54pm Wed 20th Apr, ANONYMOUS

and to add another question, would the elapsed time be checked against the system output or the real time output? because my real time output greatly differs from the system output


SVG not supported

Login to reply

👍?
helpful
3:59pm Wed 20th Apr, Ryan B.

ANONYMOUS wrote:
> Just to clarify, does 20 seconds mean 0m20.***s
Yep!
> so far my code is functioning correctly but it takes around 0m0.060s. Would I be penalised in this case?
Nope - this is 60 milliseconds, which seems reasonable (it should also be pretty clear, as your code should run 'instantly' rather than being able to count to 20 before it stops...).


SVG not supported

Login to reply

👍?
helpful
4:00pm Wed 20th Apr, Ryan B.

'Real' time - this is wall/beginning-to-end time. [stackoverflow]


SVG not supported

Login to reply

👍?
helpful
4:01pm Wed 20th Apr, ANONYMOUS

Ok thanks for the clarification!

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy