Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81096
| X-Received | by 10.66.139.169 with SMTP id qz9mr86023225pab.3.1416504817761; Thu, 20 Nov 2014 09:33:37 -0800 (PST) |
|---|---|
| X-Received | by 10.182.4.69 with SMTP id i5mr22474obi.17.1416504817539; Thu, 20 Nov 2014 09:33:37 -0800 (PST) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!uq10no1994937igb.0!news-out.google.com!m4ni325qag.1!nntp.google.com!uq10no1994933igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Thu, 20 Nov 2014 09:33:37 -0800 (PST) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=72.183.225.69; posting-account=k6DCZAoAAADhGpKVu-GNOr9e_J8ykBMN |
| NNTP-Posting-Host | 72.183.225.69 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <42700bbc-bd47-439b-aa02-dc58d8d7f513@googlegroups.com> (permalink) |
| Subject | Help with an 8th grade science project |
| From | dave em <daveandem2000@gmail.com> |
| Injection-Date | Thu, 20 Nov 2014 17:33:37 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Received-Bytes | 3320 |
| X-Received-Body-CRC | 942183413 |
| Xref | csiph.com comp.lang.python:81096 |
Show key headers only | View raw
Hello,
I am the adult advisor (aka father) to an 8th grader who is doing a science project that will compare / benchmark CPU performance between an AMD 64 Phenom II running Ubuntu 14.04 and a Raspberry Pi 700MHz ARM.
Basic procedure:
- Run a Python script on both computers that that stresses the CPU and measure
-- Time to complete the calculation
-- Max CPU during the calculation
-- We have chosen to do factorials and compare performance by running calculations by order of magnitude. Our hypothesis is that we will begin to see a wider performance gap between the two computers as the factorials increase in order of magnitude.
Status:
- We have a working program. Pseudo code follows:
import linux_metrics
from linux_metrics import cpu_stat
import time
print 'Welcome to the stress test'
number = raw_input("Enter the number to compute the factorial:")
## function to calculate CPU usage percentage
def CPU_Percent():
cpu_pcts = cpu_stat.cpu_percents(.25)
print 'cpu utilization: %.2f%%' % (100 - cpu_pcts['idle'])
write cpu utilization to a csv file with g.write
## function to compute factorial of a given number
def factorial(n):
num = 1
while n >= 1:
num = num * n
CPU_Percent() ****This is the function call irt Q 1 below ****
n = n - 1
return num
# Main program
Record start time by using time.time()
Call function to compute the factorial.
Record finish time by using time.time()
write time to compute to a file f.write(totalEndTime - totalStartTime)
print ("Execution time = ", totalEndTime - totalStartTime)
Questions:
1. In the factorial() function we call the CPU_Percent() function and write the CPU utilization value to a file.
- Is this a correct value or will the CPU utilization below lower because the factorial() function made its calculation and is now just checking the CPU utilization?
- If we are not getting the true max CPU utilization, can someone offer a design change to accomplish this?
2. What unit does time.time() use? An example for calculating the factorial of 10 is our program gives:
Execution time = ', 1.5703258514404297 I presume this is telling us it took 1.57 seconds to complete the calculation?
Thanks in advance for any help / suggestions.
Best regards,
Dave
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Help with an 8th grade science project dave em <daveandem2000@gmail.com> - 2014-11-20 09:33 -0800
Re:Help with an 8th grade science project Dave Angel <davea@davea.name> - 2014-11-20 15:13 -0500
Re: Help with an 8th grade science project Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-20 13:47 -0700
Re: Help with an 8th grade science project dave <daveandem2000@gmail.com> - 2014-11-20 13:06 -0800
csiph-web