User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Benchmarking the Pi in the shell

Mon Sep 03, 2012 11:35 pm

Being fairly new to linux and curious about the processing ability of the Pi, I was searching a script I could use to test its ability and found this:

http://tuxshell.blogspot.co.uk/2009/08/ ... hmark.html

So I use the script "time echo "scale=5000; a(1)*4" | bc -l" but encontered a problem about "bc" not being a command. What is bc? am I correct in thinking its a shell calculator? how would I go about getting this to work?

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Benchmarking the Pi in the shell

Mon Sep 03, 2012 11:45 pm

"bc" does not but "bg" tells a command to run in the background (thinks typo in the original) ;)

Just an idea :)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Benchmarking the Pi in the shell

Mon Sep 03, 2012 11:53 pm

Decimal Calculator. It works like slow interpreted C. Combined with dc and expr, any shell script can do maths. Not super fast maths, but maths. Hence down to benchmarketing. Maybe check the internet to see which package should be sudo apt-got.

If your getting into maths programming, the maybe Octave (a programming language) is more useful to benchmark. I'm not sure if full general CAS is easily available on the Pi, but I may be wrong. Anyhow, much of the newer stuff, to do with polylog and differential equation solving algebraically is bleeding edge. Google "list of finite simple groups" for some background on the "factors" of any finite solution with pattern.
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

mikerr
Posts: 2789
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Benchmarking the Pi in the shell

Mon Sep 03, 2012 11:56 pm

bc is quite a powerful command line calculator :
http://linuxjournal.com/article/2544
Android app - Raspi Card Imager - download and image SD cards - No PC required !

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 12:20 am

Thanks guys got it working by:

"sudo apt-get install bc"

Used the script:

"time echo "scale=2000; a(1)*4" | bc -l" and got
real 0m25.512s
user 0m25.450s
sys 0m0.010s

This was done on a default 700mhz Pi, if someone would like to test the same script on a 800mhz overclocked Pi and post the results that would be great to see. I may use a scale of 10000 and leave it over night and see the results I get, plus it'll be a great way to test the stability of the Pi.

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 6:35 am

You probably have the old kernal 3.1.9? (uname -a tells it)

Here are my results with that kernel:
arm_freq=800
sdram_freq=500
#BogoMIPS : 795.44
real 0m22.501s
user 0m22.140s
sys 0m0.020s

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 11:11 am

What suggests im using the old kernal? But yes, i'm using 3.1.9+

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 11:25 am

This looks fun so I thought I'd play too. :D
I tried your amended (2000) one after I noticed the 5000 version was taking rather longer than yours. :D

Mine's clocked at
BogoMIPS : 898.66
arm_freq=900
sdram_freq=450
gpu_freq=320

3 sets of results...

real 19.108s, 19.595s, 19.296s
user 18.980s, 19.470s, 19.180s
sys 0.030s, 0.020s, 0.030s

The ARM processor is a mere wart on the side of the GPU though. :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 11:43 am

Is there a way of benchmarking the gpu?

User avatar
jojopi
Posts: 3089
Joined: Tue Oct 11, 2011 8:38 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 11:52 am

http://en.wikipedia.org/wiki/John_Machin

Code: Select all

echo "scale=2011; 16*a(1/5)-4*a(1/239)" |(time bc -l)
real 0m7.592s

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 12:29 pm

The new kernel is about 10% faster, so I based my guess to your perf numbers. ;)

My results using the new kernel 3.2.27 without overclock(but with the usb patch: dwc_otg.fiq_fix_enable=1):
#BogoMIPS : 697.95
real 0m23.727s
user 0m23.660s
sys 0m0.010s

And with overclock:
arm_freq=900
sdram_freq=500
gpu_freq=400
#BogoMIPS : 898.66
real 0m18.213s
user 0m18.160s
sys 0m0.010s

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 1:36 pm

jojopi wrote:http://en.wikipedia.org/wiki/John_Machin

Code: Select all

echo "scale=2011; 16*a(1/5)-4*a(1/239)" |(time bc -l)
real 0m7.592s
That's cheating :) I got 5.717 using that method. :lol:
Alex Eames RasPi.TV, RasP.iO

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 2:18 pm

i dont suppose someone could break that script down to me so I can actually make sense of what its actually doing? :D

CianHa
Posts: 17
Joined: Sun Jul 29, 2012 9:10 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 3:17 pm

stuartheath wrote:i dont suppose someone could break that script down to me so I can actually make sense of what its actually doing? :D
The time command measures how long it takes to complete the rest of the line.
The echo command, combined with the Pipe, "|" feeds the line of BC script into the

bc -l starts the bc environment with the standard maths library loaded

I've never heard of BC before either. It's a maths language, rather than just a calculator.

The script here just contains the line :
scale=2011; 16*a(1/5)-4*a(1/239)
which I'm assuming creates a FOR loop of values form 1 to 2011, and runs the arithmetic each time?

EDIT: I started bc in interactive mode (bc -li) and ran that command. After thinking about it for a few seconds, it printed what (rather aptly), looks like an approximation of pi, presumably to 2011 places? :D

EDIT 2: The formula used above is Machin's Formula (hence the wiki link!)

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Benchmarking the Pi in the shell

Tue Sep 04, 2012 5:17 pm

I really want to upgrade my kernal now but I dont want to reset my Pi its been going for 4 days strong :geek:

marnixava
Posts: 1
Joined: Thu Feb 28, 2013 9:52 pm

Re: Benchmarking the Pi in the shell

Thu Feb 28, 2013 10:41 pm

What the

Code: Select all

time echo 'scale=5000;a(1)*4' | bc -l
does is first call the "time" command that's built-in to bash (assuming your shell is bash) in order to see how long it takes to do the rest of the command line. The

Code: Select all

echo 'scale=5000;a(1)*4'
part of the command line has instructions that are piped (via the "|") to the "bc -l" command. The "bc -l" calls the bc calculator with the math library option. The commands piped to bc are "scale=5000" and "a(1)*4". The scale command tells bc that we want precision up to 5000 places in our calculations. the "a(1)*4" computes the arc-tangent (a trigonometric function) of 1 and multiplies that by 4 which computes to the value of the constant known as Pi.

By using the built-in "time" command, you can time a line that includes a pipe. If you were to use the external /usr/bin/time command, you'd have to time just the "bc -l" part as in:

Code: Select all

echo 'scale=5000;a(1)*4' | /usr/bin/time bc -l

Return to “General discussion”