Time-consuming simple script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Time-consuming simple script
# 1  
Old 03-02-2010
Time-consuming simple script

Hi,

I need some simple but time-consuming script, I would like to compare run time in different shells. I thought about factorial or exponentiation in many loop, but I don't know it's a good idea.

Do you know some simple, time-consuming (arithmetic) script ??
I would be thankful for every help and suggestion

cheers,
Paul.
# 2  
Old 03-02-2010
Code:
i=1;j=1;while [ $i -lt 1000000 ]; do (( j = j + 1 )); ((i = i + 1 )); done;echo $j


cheers,
Devaraj Takhellambam
# 3  
Old 03-02-2010
Yeah, I was thinking about some thing like that, maybe something more sophisticated Smilie, but not too much Smilie
# 4  
Old 03-02-2010
why?
no one with any sense would do serious arithmetic in a shell script.
# 5  
Old 03-02-2010
Quote:
Originally Posted by bigearsbilly
why?
no one with any sense would do serious arithmetic in a shell script.
Yes, I know, it's just for test
# 6  
Old 03-02-2010
fisher yates shuffle?
# 7  
Old 03-02-2010
runtime in shell is largely a function of the number of builtins that you call. More builtins = fewer child processes created. Process creation is a resource hog.
In modern shells
Code:
a=4
b=3
# slow 
result=$(echo "$a * $b" | bc -l )
#faster
result=$(( $a * $b ))

So, comparing shells that do not have comparable builtins is not going to tell you much about the shell's performance ie., csh vs bash. cfajohnson knows about such things, he may comment for you.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to do simple date (time) calculation in shell script?

Hi, I'm looking for a way to do a simple math calc during a shell script as a means of logging how long a particular task takes. For example... STARTTIME=whenever this script starts ./path/to/command.sh >>logfile.log TOTALTIME=<time at this stage of the script after above command... (7 Replies)
Discussion started by: nbsparks
7 Replies

2. Shell Programming and Scripting

Simple date and time calulation in BASH

There is a closed Thread: <url>Here will be the url to the original post once I have 5 posts in this forum...</url> But a small bug had found his way into this very cool and simple code. #!/bin/bash date2stamp () { date --utc --date "$1" +%s } stamp2date (){ date --utc --date... (2 Replies)
Discussion started by: frood
2 Replies

3. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

4. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

5. Shell Programming and Scripting

Unix shell script to query linux top consuming processes

Hi All, O/S: Linux 86x64 Red Hat I have a sql script that queries top consuming processes of Linux using TOP commnd. Now I need to automate this task and pass the top processes i.e., PID to the sql script through unix shell script. Could anyone please let me know how to achieve this. ... (2 Replies)
Discussion started by: a1_win
2 Replies

6. Shell Programming and Scripting

Crontab - wrote Simple Script but i cant work out how to play it at a certain time.

Hi everyone. Silly might be silly be I'm still new to bash. I'm trying to make an Alarm Clock for in the morning using my laptop i have wrote this Simple Script but i cant work out how to play it at a certain time. #!/bin/bash cd /home/josh/Music/Bruno_Mars/Hooligans/ cvlc... (8 Replies)
Discussion started by: jtsmith90
8 Replies

7. HP-UX

which thread is consuming much time ?

Hi How do i check which thread is consuming much time ? In my process it is tacking much %CPU so i want to check whick thread tacking much time? Any suggestion highly appriciated. I am using HP-UX B.11.31 U ia64 Regards, Ashok (5 Replies)
Discussion started by: ashokd001
5 Replies

8. Tips and Tutorials

Simple date and time calulation in BASH

The GNU date command in full of goodies but not when it comes to calculate a date or time difference. Here is what I came up with after looking to more than one solution. Code should be self explaining. #!/bin/bash date2stamp () { date --utc --date "$1" +%s } stamp2date (){ ... (0 Replies)
Discussion started by: ripat
0 Replies

9. UNIX for Dummies Questions & Answers

How ti kill a process which is consuming so much time

There is a process which is consuming too much time.. how to find that process and kill it. (3 Replies)
Discussion started by: shreenivas
3 Replies
Login or Register to Ask a Question