Overclocking & Benchmarking the Raspberry Pi


The Raspberry Pi is powered by an ARM SOC (System On a Chip) running at 700MHz. It is possible to increase this speed in order to squeeze some extra processing power out of the CPU. It is also possible to increase the speed of the Graphics Processing Unit (GPU) and the onboard RAM.

The default speeds are :

  • CPU – 700MHz
  • RAM – 400MHz
  • GPU – 250MHz

Benchmarking – Method #1

In order to see what difference overclocking might make I decided to perform a simple benchmarking test. To do this I created a Python script that would perform a set task and work the CPU. This would allow me to measure the time it took the script to run before and after making any changes. The script searches for prime numbers within a number range and is shown below :

# Generate prime numbers
# Based on an article from http://dunningrb.wordpress.com/

import datetime, sys, math

# Function to print message
def print_prime(x):
  print " Prime : %7i " %x

# Function to search for prime numbers
# within number range
def find_primes(upper_limit):
  count = 0
  candidate = 3
  while(candidate <= upper_limit):
    trial_divisor = 2
    prime = 1 # assume it's prime
    while(trial_divisor**2 <= candidate and prime):
      if(candidate%trial_divisor == 0):
        prime = 0 # it isn't prime
      count += 1
    candidate += 2
  return count
# Check if the script was called with a
# parameter. Use that as the upper limit
# of numbers to search
if len(sys.argv) != 2:

# Record the current time
startTime = datetime.datetime.now()

# Start the process
print ""
print "Starting ..."
print ""
count = find_primes(upper_limit)
print ""

# Measure and print the elapsed time
print " Found %d primes in %s" %(count,elapsed)
print ""

This can be run with the following command line :

python findprime.py

This will look for all prime numbers up to 1,000,000 and state how long it took to find them. If you want to change the range you can use the following command line :

python findprime.py 50000

It takes my Pi about 590 seconds to calculate all the prime numbers smaller than 1,000,000. The time can vary so it is worth running the script a few times to get a feel for the average.

Benchmarking – Method #2

You can also use the following command line to time a CPU intensive calculation :

time echo "scale=3000;4*a(1)" | bc -l

You may need to install the bc package for the above to work. In Debian this is easily done using :

sudo apt-get install bc


Once I had some benchmarks I decided to increase the CPU clock speed. You can change the CPU, GPU and memory clock speeds by editing the config.txt file in the /boot/ directory. This is the boot partition and is readable in Windows if you insert your SD card into a card reader. There are lots of options that can be set in this file and these are documented in http://elinux.org/RPi_config.txt. I wouldn’t recommend changing any of them unless you are sure you know what you are doing!

The following command can be run on the Pi to either edit the existing file or create a new one if it doesn’t already exist.

sudo nano /boot/config.txt

The entries that you can add or edit are :


Change the values and using CTRL-X then Y save the file. Type the following command to reboot the Pi :

sudo reboot


Running findprime.py with default settings took 590 seconds. Increasing the CPU frequency to 800MHz reduced this to 530 seconds. This is an increase of 11%.

I then increased the RAM frequency to 500MHz. This made almost no difference. This isn’t a huge surprise as the script is more CPU intensive than it is memory intensive so the memory speed increase isn’t going to help with the number crunching.

So my current settings are :


I’m not intending on increasing the speed beyond 800MHz. It’s early days and I don’t want to destroy my Pi while replacements are hard to acquire.

At the moment I’ve got no way of benchmarking graphical performance so I haven’t experimented with the GPU settings.



    • Hi Mark, I think the “return count” was not indented properly. I have updated the script. I added two spaces in front of “return count” on line 26.

  1. Crikey!
    Just tried:

    Halves the time for generating 25000 primes.
    Thanks for the pointer! I think I’m getting underpower on the USB ports, though.

  2. Just an FYI Post using this method of benchmarking.
    ARM: 900
    Core: 275

    Avg (over three runs): 393 Seconds (6:55 minutes)

    Stock Settings
    Avg (over three runs): 430 Second (7:18 minutes)

    In addition, the responsiveness of the system just seems to feel a bit better with the overclocking.

  3. Pingback: Overclocking Raspbmc - IT Cave - La Cueva SI

  4. Renier Kleinhans on

    I copied and paste your code, but when I run it, it gave me an error.
    I’m new to all of this.

    File “findprime.py”, line 15
    while(candidate <= upper_limit):
    ^ appears under the ; when I run the code but it is not in the code.

    Any help would be appreciated.

  5. Pingback: Raspberry Pi Overclock: Turbo Mode for increased performance | Root Users

  6. Pingback: Benchmarking The Raspberry Pi 2 | Hackaday

  7. Pingback: Benchmarking The Raspberry Pi 2 | 0-HACK

  8. Hi,
    I tried this on RPi2 with :

    The result is :
    Found 78497 primes in 0:01:37.999941

    Wow !

    Then I tried 4 concurrent tasks to check for quad-core improvements :
    $ python test.py >1 & python test.py >2& python test.py > 3& python test.py
    [1] 4511
    [2] 4512
    [3] 4513
    Starting …
    Found 78497 primes in 0:01:38.716324
    [2]- Done python test.py > 2
    [1]- Done python test.py > 1
    [3]+ Done python test.py > 3
    pi@retropie ~ $ cat 1 2 3
    Starting …
    Found 78497 primes in 0:01:41.330831
    Starting …
    Found 78497 primes in 0:01:37.950976
    Starting …
    Found 78497 primes in 0:01:42.662671

    Amazing !

  9. Pingback: Raspberry Pi Zero vs. PocketBeagle | Teach Me Microcontrollers!

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.