Close Menu
    Facebook X (Twitter) Instagram Pinterest YouTube
    Trending
    • Disable SSH Password Login on Raspberry Pi
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    Mastodon YouTube Facebook Instagram Pinterest RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        February 16, 2024

        Disable SSH Password Login on Raspberry Pi

        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Overclocking & Benchmarking the Raspberry Pi
      Raspberry Pi Model B+

      Overclocking & Benchmarking the Raspberry Pi

      16
      By Matt on June 13, 2012 Hardware

      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
            trial_divisor+=1
          if(prime):
            print_prime(candidate)
            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:
        upper_limit=1000000
      else:
        upper_limit=int(sys.argv[1])
      
      # 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
      elapsed=datetime.datetime.now()-startTime
      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

      Overclocking

      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 :

      arm_freq=700
      sdram_freq=400
      gpu_freq=250

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

      sudo reboot

      Results

      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 :

      arm_freq=800
      sdram_freq=500
      gpu_freq=250

      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.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleControl LED Using GPIO Output Pin
      Next Article Raspberry Pi Speakers & Analog Sound Test

      Related Posts

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      Pi Pico Pinout Display on the Command Line

      How to Add a Raspberry Pi Pico Reset Button

      16 Comments

      1. Julian on June 26, 2012 3:47 pm

        Maybe this could be interesting for you:
        http://www.bit-tech.net/hardware/pcs/2012/04/16/raspberry-pi-review/7

        Reply
      2. Mark on July 13, 2012 2:41 pm

        findprime.py = Syntax error line #26 ‘return outside function’?

        Any ideas?

        Cheers

        Mark

        Reply
        • Matt on July 15, 2012 7:18 pm

          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.

          Reply
      3. Mark on July 16, 2012 7:42 pm

        Thankyou Matt, that’s done the trick for me! 8)

        Reply
      4. Michael Horne on July 18, 2012 1:26 pm

        Crikey!
        Just tried:
        arm_freq=800
        sdram_freq=500
        gpu_freq=250

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

        Reply
      5. Gareth on July 28, 2012 7:22 am

        Just an FYI Post using this method of benchmarking.
        Settings
        ARM: 900
        Core: 275
        SDRAM:500

        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.

        Reply
      6. Pingback: Overclocking Raspbmc - IT Cave - La Cueva SI

      7. Renier Kleinhans on October 15, 2014 1:20 pm

        Hi,
        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.

        Reply
        • Matt on October 15, 2014 3:11 pm

          Give it a try now. The less-than symbols had been incorrectly rendered on the page. They should be correct now.

          Reply
          • Renier Kleinhans on October 15, 2014 4:15 pm

            Tx work like a charm.

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

      9. Pingback: Benchmarking The Raspberry Pi 2 | Hackaday

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

      11. Gdz on October 20, 2015 2:38 pm

        Hi,
        I tried this on RPi2 with :
        arm_freq=1000
        core_freq=500
        sdram_freq=500
        over_voltage=6

        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 !

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

      13. Khalil Nurullah on August 1, 2019 2:47 am

        Pi 4:
        Found 78497 primes in 0:00:24.769203

        Reply
      Leave A Reply Cancel Reply

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

      Recent Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2025 - All Rights Reserved - Matt Hawkins

      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Latest Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      Mastodon YouTube Instagram Facebook Pinterest RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2025 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.