Faculty of Engineering and Mathematical Sciences 
Not logged in (login)


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).
RSS cloud
Jump to:

Assign 2 Q2 - execution time very long

1 of 390 articles shown, currently no other people reading this forum.
From: Christopher M.
Date: Tue 19th May 2020, 12:12pm


"Fraser Loneragan" <22*4*4*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> Currently my code takes a very long time to process through all of secure-access.log-
> 20200510 (like 45 minutes on my laptop). Are there any marks or penalties for slow 
> executing code? For ref in my while loop which iterates through every line i so far 
> have an awk command, a reg exp check (in an if statement) and an array append. 

Hi Fraser,

45 minutes is clearly far too long (but I admire your patience!).
Invoking new processes takes the most time and, I suspect, that you're invoking awk for every 
line of the log file 93000x).

Can you restructure your approach, so that you invoke external programs, such as awk, far fewer 
times (maybe just once).  Feed the input file to awk, have it read each line, perform the RE 
matches on each line, and leaving its results, even temporary results in external files, rather 
than in shell variables.


Related articles

Assign 2 Q2 - execution time very long (all 3) RSS
├─ original   Tue 19th May 2020, 11:56am, Fraser L.
├─ THIS   Tue 19th May 2020, 12:12pm, Christopher M.
└─ reply 2   Tue 19th May 2020, 3:22pm, David M.
This Page

Program written by: [email protected]
Feedback welcome
Last modified:  2:34pm Sep 18 2020