Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-01-2012
pandeesh's Avatar
Registered User
 
Join Date: Jul 2011
Posts: 314
Thanks: 77
Thanked 12 Times in 12 Posts
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
Sponsored Links
    #2  
Old 07-01-2012
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,738
Thanks: 179
Thanked 662 Times in 638 Posts
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.
Sponsored Links
    #3  
Old 07-01-2012
pandeesh's Avatar
Registered User
 
Join Date: Jul 2011
Posts: 314
Thanks: 77
Thanked 12 Times in 12 Posts
So how we can measure the performance of a script in general?
    #4  
Old 07-01-2012
balajesuri's Avatar
#! /bin/bash
 
Join Date: Apr 2009
Location: India
Posts: 1,626
Thanks: 15
Thanked 458 Times in 442 Posts
One parameter would be to measure the time taken to run the script.
Sponsored Links
    #5  
Old 07-01-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,706
Thanks: 130
Thanked 742 Times in 621 Posts
Quote:
Originally Posted by pandeesh View Post
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
Sponsored Links
    #6  
Old 07-01-2012
pandeesh's Avatar
Registered User
 
Join Date: Jul 2011
Posts: 314
Thanks: 77
Thanked 12 Times in 12 Posts
Quote:
Originally Posted by balajesuri View Post
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 ?
Sponsored Links
    #7  
Old 07-01-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,706
Thanks: 130
Thanked 742 Times in 621 Posts
time

Regards,
Alister
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unsure of sed notation (nu\\t.\*) czar21 Shell Programming and Scripting 3 07-20-2011 04:52 PM
Convert decimal notation to ANSI point code notation aavam Shell Programming and Scripting 4 06-28-2011 09:16 PM
IP Address Notation JerryHone IP Networking 5 02-18-2011 01:19 AM
Sorting exponential notation NilsMueller Shell Programming and Scripting 15 09-14-2010 01:40 AM
Rounding scientific notation ppat7046 Shell Programming and Scripting 4 06-10-2009 02:20 PM



All times are GMT -4. The time now is 01:17 PM.