Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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" > '
@ 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.
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.....?
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?
@ 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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.