LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 03:07 PM   #1
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 308

Rep: Reputation: Disabled
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, 03:18 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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, 03:18 PM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

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

Original Poster
Rep: Reputation: Disabled
@ 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 03:30 PM.
 
Old 07-27-2008, 03:28 PM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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, 03:29 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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, 03:34 PM   #7
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 308

Original Poster
Rep: Reputation: Disabled
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 03:37 PM.
 
Old 07-27-2008, 03:38 PM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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 03:40 PM.
 
Old 07-27-2008, 03:44 PM   #9
tommytomthms5
Member
 
Registered: Sep 2007
Distribution: debian based
Posts: 308

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

Rep: Reputation: 63
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



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 12:47 AM
Annoying or helpful MensaWater General 2 04-16-2007 10:00 AM
Anywhere to go for helpful commands? MooCows Linux - Newbie 7 12-30-2004 04:33 PM
You know what would be extremely helpful... breezewax Linux - Software 3 09-06-2004 06:18 PM
Would a router be helpful RoughEdge Linux - Networking 1 01-09-2004 12:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 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
Open Source Consulting | Domain Registration