Shell script and Big O notation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell script and Big O notation
# 1  
Old 07-01-2012
Shell script and Big O notation

I am wondering why big O notation is not being emphasized in shell script context. But its almost discussed in all OOP languages,
Please shed your thoughts,

Thanks
# 2  
Old 07-01-2012
Shell sits on top of so much other stuff, that anything that would merit O notation would already be in a low level language where you can directly control all of the "stuff", like I/O, buffering, memory ordering, etc.

Shell also suffers from performance degradation when coders are oblivious to the cost of process creation - e.g., writing loops that iterate over a miilion lines of a file, with dozens of external commands embedded, instead of using builtins and keywords.
# 3  
Old 07-01-2012
So how we can measure the performance of a script in general?
# 4  
Old 07-01-2012
One parameter would be to measure the time taken to run the script.
# 5  
Old 07-01-2012
Quote:
Originally Posted by pandeesh
So how we can measure the performance of a script in general?
Big O notation does not in itself provide you with any useful performance information; it's merely one characteristic of an algorithm's complexity.

O(n) is usually better than O(n^2), but if you're working on a small data set and the O(n) approach requires some expensive setup to begin, the O(n^2) solution could be the better choice.

In the end, you need to test the code with what will be a typical workload, under typical operating conditions, on typical hardware.

Regards,
Alister
# 6  
Old 07-01-2012
Quote:
Originally Posted by balajesuri
One parameter would be to measure the time taken to run the script.
Do we have any shell built in feature to measure the execution time of a script rather than manually monitoring ?
# 7  
Old 07-01-2012
time

Regards,
Alister
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Big problem: shell entry in /etc/passwd corrupted for user root

did a big mistake, changing root entry of /etc/passwd to root:x:0:0:root:/root:/usr/bin/tmux split-window -v \; attach as expected, now I can't login as root anymore. sudo ed /etc/passwd etc. doesn't work. Any idea? Use code tags to increase readability and follow the rules. (4 Replies)
Discussion started by: dodona
4 Replies

2. Shell Programming and Scripting

Perl: scientific notation to decimal notation

hello folks, I have few values in a log which are in scientific notation. I am trying to convert into actual decimal format or integer but couldn't able to convert. Values in scientific notation: 1.1662986666666665E-4 2.0946799999999998E-4 3.0741333333333333E-6 5.599999999999999E-7... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

C-script notation

Just a very brief question, but I have a script written in a C-like language possibly tcl with the line set var ... ...All I want to know, is ** multiplication or is it exponentiation? What is the ** operator? (1 Reply)
Discussion started by: chrisjorg
1 Replies

4. Shell Programming and Scripting

Convert decimal notation to ANSI point code notation

wondering if anyone has any thoughts to convert the below thru a shell script Convert decimal signalling point notation to ANSI point code notation There is a site that does that conversion but i need to implement the solution in a shell script.....Thoughts.... OS: Solaris 9 ... (4 Replies)
Discussion started by: aavam
4 Replies

5. UNIX for Dummies Questions & Answers

How big is too big a config.log file?

I have a 5000 line config.log file with several "maybe" errors. Any reccomendations on finding solvable problems? (2 Replies)
Discussion started by: NeedLotsofHelp
2 Replies

6. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

7. UNIX for Dummies Questions & Answers

How to view a big file(143M big)

1 . Thanks everyone who read the post first. 2 . I have a log file which size is 143M , I can not use vi open it .I can not use xedit open it too. How to view it ? If I want to view 200-300 ,how can I implement it 3 . Thanks (3 Replies)
Discussion started by: chenhao_no1
3 Replies
Login or Register to Ask a Question