Script in Python to run a C program

Aahz Maruch aahz at panix.com
Thu Sep 21 06:03:55 CEST 2000


In article <00092100044500.01350 at localhost.localdomain>,
The Majestic Moined Mogul  <mogulNOSPAM at primus.ca> wrote:
>Could someone please tell me how to best write a Python script that could
>execute a C program several times and compare the run times of each?

times = []
for i in range(numTests):
  start = time.time()
  os.system(cmd)
  end = time.time()
  times.append( (start,end) )

I don't claim this is "best", but it sure is simple.  You might want to
include a call to os.system(cmd) before the loop to pre-load the disk
cache.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Member of the Groucho Marx Fan Club  --Aahz



More information about the Python-list mailing list