LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2008, 04:07 PM   #1
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 305

Rep: Reputation: 30
helpful: useful little script for benchmarking...


this is my benchmarking script it runs completely clean as in it removes all temporary files after they are used.



Code:
#!/bin/ksh
IFS=$'\n'
echo "benchmaring..."
start=$SECONDS
for i in $(ls ./);
do a=0;
while [ "$a" -ne "1000" ];
do echo "$a " > .testfile;
let a++;
done;
stop=$SECONDS
((runtime=stop-start))
rm .testfile
echo "file with 1k lines created and destroyed in $runtime seconds" > .time
done;
cat .time
rm .time
echo "wow that was fast!"
just copy and paste into benchmark.sh then run

sh benchmark.sh

now i know ive posted stupid scripts before but if you read through it its completely clean and removes all the temporary files it makes... on top of that i used a realistic way of creating a process then ending it... so no jokes no pranks no kidding just a useful little script




if you feel like posting your outputs please do!
 
Old 07-27-2008, 04:18 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
I get this:
Code:
ray@spinelli:~$ sh benchmarking.sh
benchmarking...
benchmarking.sh: line 14: syntax error near unexpected token `newline'
benchmarking.sh: line 14: `echo "file with 1k lines created and destroyed in $runtime seconds" > '
Running Debian Lenny
 
Old 07-27-2008, 04:18 PM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Benchmarks are designed to test the performance of something. What is the something here?
 
Old 07-27-2008, 04:28 PM   #4
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 305

Original Poster
Rep: Reputation: 30
@ Mr. C >> it was supposed test how fast you can make and destroy a file that has 1000 lines yet i found an error in it... it just rewrites one line 1000 times then deletes it... messed up on the "echo %a > .testfile" line i should first create the file then do "echo %a >> .testfile"

Last edited by tommytomthms5; 07-27-2008 at 04:30 PM.
 
Old 07-27-2008, 04:28 PM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
For some reason .time was being interpreted as being on it's own line. Slightly revised code is:
Code:
#!/bin/bash
	IFS=$'\n'
	echo "benchmarking..."
	start=$SECONDS
	for i in $(ls ./);
	do a=0;
		while [ "$a" -ne "1000" ];
	do echo "$a " > .testfile;
		let a++;
	done;
		stop=$SECONDS
		((runtime=stop-start))
		rm .testfile
		echo "file with 1k lines created and destroyed in $runtime seconds" > .time
	done;
	cat .time
	rm .time
	echo "wow that was fast!"
I changed to bash from ksh, no reason why it couldn't be changed back.
The response on my laptop is
Code:
benchmarking...
file with 1k lines created and destroyed in 2 seconds
wow that was fast!
I don't know if that is fast as I have nothing to compare it with.....?
 
Old 07-27-2008, 04:29 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
I got:
Code:
benchmaring...
file with 1k lines created and destroyed in 1 seconds
wow that was fast!
But fast what? I tested in a directory with 2 dummy subdirectories. If I had tested from a directory containing 50000 subdirectories, the response would have been "wow that was fast!"...

Anyway, as Mr.C pointed out it is not really clear what is the aim of this "benchmarking" tool. If it is disk I/O... have you ever heard about the good ol' bonnie or Iozone filesystem benchmark?

Also a good code would at least use indentation!

Is my critique too destroying?
 
Old 07-27-2008, 04:34 PM   #7
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 305

Original Poster
Rep: Reputation: 30
well... i see all your points and yea i guess you do sorta need a comparison for this to work right....



oh and as said b4 i found that i messed up it doesnt write 1000 separate lines it rewrites one line 1000 times

Last edited by tommytomthms5; 07-27-2008 at 04:37 PM.
 
Old 07-27-2008, 04:38 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Quote:
Originally Posted by tommytomthms5 View Post
@ Mr. C >> it was supposed test how fast you can make and destroy a file that has 1000 lines yet i found an error in it... it just rewrites one line 1000 times then deletes it... messed up on the "echo %a > .testfile" line i should first create the file then do "echo %a >> .testfile"
Colucix understood my point. What your test actually benchmarks is how fast the shell can run a loop. This is very different from how fast the system can append a line to the end of a file.

Benchmarks require very careful analysis and construction of the proper procedures to ensure you are actually testing what you think you are testing. The shell is an interpreter, and is a fairly slow one. Because of that, your benchmark is limited by the speed of the slow shell. File I/O is very fast, and its impact is insignificant relative to the shell loop speed - so it is hidden in the noise.

Last edited by Mr. C.; 07-27-2008 at 04:40 PM.
 
Old 07-27-2008, 04:44 PM   #9
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 305

Original Poster
Rep: Reputation: 30
tell me more of this "file i/o"
 
Old 07-27-2008, 04:46 PM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Download, build, and run bonnie or bonnie++ and see how fast your I/O really occurs on your system. That will show you the speed difference, and start you off towards understanding File input and output (I/O).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
It will be helpful for all the Ubuntu users... mrphoenix Linux - Newbie 3 07-18-2008 01:47 AM
Annoying or helpful MensaWater General 2 04-16-2007 11:00 AM
Anywhere to go for helpful commands? MooCows Linux - Newbie 7 12-30-2004 05:33 PM
You know what would be extremely helpful... breezewax Linux - Software 3 09-06-2004 07:18 PM
Would a router be helpful RoughEdge Linux - Networking 1 01-09-2004 01:04 PM


All times are GMT -5. The time now is 07:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration