# How Fast is Your Computer?

## Abstract

Is your computer fast? How quickly do you think it can do 100 million arithmetic problems? Do you think it could beat your friend's computer or another one at school? Try this science project to discover an easy way to measure whether or not your computer is a math whiz.## Objective

Measure how long it takes your computer to perform mathematical operations (addition, subtraction, multiplication, and division) with different types of numerical data.

## Credits

Andrew Olson, Ph.D., Science Buddies

Sandra Slutz, Ph.D., Science Buddies

## Cite This Page

### MLA Style

*Science Buddies*. Science Buddies, 1 Oct. 2014. Web. 29 Mar. 2015 <http://www.sciencebuddies.org/science-fair-projects/project_ideas/CompSci_p011.shtml>

### APA Style

*How Fast is Your Computer?.*Retrieved March 29, 2015 from http://www.sciencebuddies.org/science-fair-projects/project_ideas/CompSci_p011.shtml

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.Last edit date: 2014-10-01

## Introduction

Have you ever sat down at an old computer, turned it on, tried to open a program, and found yourself waiting... and waiting... and waiting... until *finally* the program opens? It probably doesn't even take that long! It takes maybe a couple of seconds or a minute, certainly not long enough to even eat an ice cream cone or listen to a new MP3, yet it feels like forever. Computer technology keeps advancing at an amazing pace, and today's computers run a *lot* faster than computers from ten or even five years ago. We've gotten used to the newer, faster computers, and it is hard to go back.

How much faster are newer computers? Is your computer faster than your friend's? Is there a way to measure how fast a computer is? The answer is yes! Just like a sprint can tell you who is the fastest short-distance runner, a mathematical computer race can show you which computer is the fastest. In fact, manufacturers race computers all the time to test their computers and to advertise who has the fastest computer. They call this testing **benchmarking**. You can test your own computer, but before you do, it is a good idea to know a little more about how a computer works and what it takes to make one faster.

Computers get instructions when you, the user, tell them to do something through clicks of the mouse, taps on the keyboard, or some less common input, like writing on a tablet, issuing voice commands, or using a joystick. These instructions, called **inputs**, tell the **software** (computer program) to do something. The exact instructions are usually processed (understood and acted on) by the **central processing unit (CPU)** which is part of the computer's **hardware**. The CPU, the "brain" of the computer, does the actual tasks and then stores the results in the computer's **memory**. For example, the software on your computer changes the task from something you understand in words, like "color this square green," to a logical or mathematical operation for the CPU to perform, like "increase the color by 50 units and store the new color value in the memory." Increasing the processing speed of the CPU or the amount of available memory are two common ways to make a computer faster.

Modern computers can also **multitask**, meaning that the **operating system** (the software that runs the basics operations of the computer) splits the CPU's attention between many programs running at once. Just like you can eat a cookie, talk to a friend, reply to a text message, listen to your MP3 player, and window shop all at the same time, a computer can do a bunch of things at a time. The more things you ask it to do, however, the slower it might seem.

In this science project, you will use a free program, called a Java timing applet, to measure how long it takes for your computer to perform four different mathematical operations: addition, subtraction, multiplication, and division. You will test the speed of your computer in each of these operations for four different ways of storing numbers, called **data types**: integers, long integers, floating-point numbers, and double-precision floating-point numbers. Both the **integer** and **long-integer** data types only store *integers* (counting numbers such as 1, 2, 3; no fractions) and can be either positive (+) or negative (-). The difference is that the long-integer data type can store larger numbers because it takes up more memory (64 **bits**) than the integer data type (32 bits).** Floating-point** numbers and **double-precision floating-point** numbers are both data types that store *non-integers*, such as numbers with decimals. Both of these data types can also store positive numbers (like 1.55) or negative numbers (like -1.55). The floating-point data type has a smaller range of numbers because it only uses 32 bits of memory. Because the double-precision floating point number data type uses 64 bits of memory, it has a larger range. Table 1 below gives examples of all four data types.

Data Type | Type of Number | Amount of Memory Used | Range of Values That Can Be Stored |

Integer | Integer | 32 bits | -2147483648 to 2147483647 |

Long integer | Integer | 64 bits | -9223372036854775808 to 9223372036854775807 |

Floating point | Non-integer | 32 bits | ±1.4E-45 to ±3.4028235E+38 |

Double-precision floating point | Non-integer | 64 bits | ±4.9E-324 to ±1.7976931348623157E+308 |

**Table 1.**The four data types listed above take different amounts of memory to store either integers or non-integers. This table was modified from David Flanagan's book

*Java In a Nutshell*; see the Bibliography for more details.

Measuring how long it takes your computer to solve different math problems and store answers provides useful information. Programmers use measurements to develop programs that will run quickly. Computer manufacturers use measurements as a benchmark comparison between two computers. However, you must keep in mind that with today's multitasking operating systems, measuring the execution time of any single process is difficult. The operating system splits CPU time between *all* of the programs that are running. No program has exclusive access to the CPU. Generally, your computer works so fast that you don't notice that it's doing multiple things at one time, especially if programs appear to respond instantly. Behind the scenes though, each program that is open or running is getting a slice of the computer's attention (CPU time), then waiting for its next turn before it can run again.

In order for the applet to give you a best estimate of how long the math takes, you should close as many applications as possible, and make sure that any open applications are not performing tasks that require lots of CPU time (e.g., printing files or downloading content from the Internet) when you run your tests.

## Terms and Concepts

To do this project, you should do research that enables you to understand the following terms and concepts:

- Benchmarking
- Inputs
- Software
- Central processing unit (CPU)
- Hardware
- Memory
- Multitasking
- Operating system
- Data types
- Integers
- Long integers
- Floating points
- Double-precision floating points

- Bits

### Questions

- Which data type do you predict your computer will process most quickly? Which do you predict your computer will process most slowly?
- How does the Java timing applet work?
*Hint:*See the Technical Note in the Experimental Procedure. - Why are older computers slower than newer ones?
- When manufacturers sell a computer, they list the "processor speed." What does this mean?
- Why does it matter how much memory a computer has?

## Bibliography

- Evslin, Tom. (2008, April).
*Why Old Computers Get Slow.*Retrieved May 24, 2011, from http://blog.tomevslin.com/2008/04/why-old-compute.html - Fay-Wolfe, Victor. (2005, December).
*How the Computer Works: The CPU and Memory.*Retrieved May 25, 2011, from http://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading04.htm - Flanagan, David. (2001). "Primitive Data Types. In
*Java In a Nutshell*(Ch. 2.4). Retrieved May 25, 2011, from http://docstore.mik.ua/orelly/java-ent/jnut/ch02_04.htm - Wikipedia Contributors. (2011, May 20). Benchmarking (Computers).
*Wikipedia: The Free Encyclopedia.*Retrieved May 25, 2011, from http://en.wikipedia.org/w/index.php?title=Benchmark_(computing)&oldid=430003721

## News Feed on This Topic

*Note:*A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

## Materials and Equipment

- Computer with Java-enabled web browser and Internet access
- Calculator or spreadsheet program, such as Excel®, for analyzing data
- Lab notebook
- Graph paper

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Experimental Procedure

- First, do your background research, and make sure that you understand the terms and concepts and can answer the questions above.
- Create a data table, like the one below, in your lab notebook or spreadsheet program.
*Note:*If you use a spreadsheet program, remember to print out your table when you are done and paste it in to your lab notebook.

Computer | Data Type | Mathematical Operation | Trial # | # of Calculations | Total Time To Perform Calculations, Milliseconds (ms) |

**Table 2.**Create a spreadsheet or data table like this to record your results.

- Close all other applications that are running on your computer. Leave only this Project Idea open.
- Use the Java timing applet below to measure the execution time for each of the mathematical operations (addition, subtraction, multiplication, and division) using each of the data types (integer, long integer, floating point, and double-precision floating point).
- Choose integer (int) from the Set Data Type options.
- Choose addition (+) from the Set Operation to Perform options.
- Set Number of Iterations to 10,000 (the default setting).
- Run the applet at least 20 times. Each time you run the applet it will return the amount of processing time in milliseconds (ms) that it takes your computer to run all 100 million calculations using that data type and mathematical operation. See the Technical Note to learn more about how the applet works.
- Record the time results of all 20, or more, trials in your data table.
- Repeat steps a–e for all the possible combinations of data types and mathematical operations. In the end there should be 16 combinations each with 20 trials.

**Note:** If you see a gray box with a red "X" in the corner, you will need to update your Java Runtime Environment in order to run this applet. Go to http://www.java.com to get the latest version.

**Technical Note #1**

The Java timing applet works through a series of commands:

- First, it tells the computer to record the start time.
- Then, it gives the computer two commands, we'll call those
*a*and*b*.- Command
*a*, tells the computer to take two numbers from a list. The list it uses can be made up of integers, long integers, floating points, or double precision floating points, depending upon which option you chose. These two numbers are used in an arithmetic operation (addition, subtraction, multiplication, or division, depending upon which option you chose). Command*a*is repeats 10,000 times (each time with a new set of numbers), making it a*loop*. - The next command,
*b,*tells the computer to repeat command*a*a certain number of times. You can choose the number of repeats (or*iterations*) by changing the Set Number of Iterations field in the applet. The default (or standard if you don't change it) is to iterate 10,000 times. This means that the computer is doing a total of 10,000 x 10,000 (10 8 or 100 million) arithmetic calculations each time you run the applet. - When command
*b*is done, the next command from the Java timing applet is to record the end time. - The final command is to subtract the start time from the end time and display that on the screen. The time, in milliseconds (ms), that it takes to do all 100 million calculations appears on the screen.

- Command

### Analyzing Your Data

- Use a calculator or spreadsheet program, such as Excel, to calculate the average processing time for each combination.
- Make four bar graphs to examine if the amount of time your computer needed to do a single type of mathematical operation (like addition) changes with different data types.
- Make one bar graph for each type of mathematical operation. There will be a total of 4 graphs: addition, subtraction, multiplication, and division.
- Each graph should have four bars on the x-axis, one for each data type.
- The height of each bar, on the y-axis, should be equal the average time for that combination.
- Look at all four bar graphs. Are any of the data types slower than the others or faster than the others? How do your predictions about processing time and data type compare with the actual results? Were you surprised? If so, can you think of an explanation for what is going on?

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Variations

- Try running the applet on different computers whose processor type and speed you know and compare the results. Keep conditions as similar as possible by minimizing the number of additional programs running. How do the times compare for computers that have the same processor types but different speeds? How do the times compare among computers with different processor types?
- Do your results change if you have other programs running while you make measurements with the applet? Does it matter if they are actually doing something or not?
- Here's an idea for analyzing your data further: How many clock cycles does each operation take? If you know the "speed" of your processor (in MHz or GHz), you can calculate this by multiplying the time per operation (in seconds) by the processor frequency (in hertz).
- For a more advanced science project, use JavaScript to write your own program to investigate execution time for a function call or writing data to the screen. For example: how long does it take to generate a random number using Math.random()? How does this compare with calculating the sine of an angle using Math.sin()? How does this compare to simple arithmetic operations in JavaScript? Can you estimate how many arithmetic operations are performed to generate a random number? How long does it take to write a line of text to the screen? How does this compare with changing the background color?
- For an even more advanced science project, use a C or C++ compiler to write a native timing program. Because Java is an interpreted programming language, it is likely that your native compiled C program will run faster than the Java applet. Is this the case?

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.Ask an Expert

## Related Links

## If you like this project, you might enjoy exploring these related careers:

### Computer Systems Analyst

Computer systems analysts have to know what computer programs and related tools are needed to efficiently get a job done. The jobs are usually carried out by other people, but the computer systems analyst makes sure the team has the right computer-based aids they need to do it. A computer systems analyst has to stay on top of the latest technologies, know the capabilities and limitations of different computer parts, and put all of this information together to help a group of people succeed. Read more### Computer Hardware Engineer

Whether you are playing video games, surfing the Internet, or writing a term paper, computers are an integral part of our daily lives. Computer hardware engineers work to make computers faster, more robust, and more cost-effective. They design the microprocessor chips that make your computer function, along with the equipment that makes computing easy and fun to do. Read more### Computer Programmer

Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more## News Feed on This Topic

*Note:*A computerized matching algorithm suggests the above articles. It's not as smart as you are, and it may occasionally give humorous, ridiculous, or even annoying results! Learn more about the News Feed

## Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity