Ignore:
Timestamp:
Feb 2, 2012, 1:08:40 PM (12 years ago)
Author:
pittj
Message:

metalog and ex1 merge added, code is now correct across all major experiments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/mem_time_tests/parameters/timestep/main.py

    r8326 r8328  
    1919file = 'ex1.csv'
    2020file_path = os.path.join(scenariodir, file)
    21 store ='store.txt'
    22 file_path_store = os.path.join(scenariodir, store)
     21meta = 'metalog.csv'
     22meta_path = os.path.join(scenariodir, meta)
     23final = 'final.csv'
     24final_path = os.path.join(scenariodir, final)
    2325
    24 spamWriter = csv.writer(open(file_path, 'wb'))
    25 spamWriter.writerow(['TimeStep' , 'Time Taken','Space Used'])
    26 
    27 e = open(file_path_store,'a') # create file
    28 e.close()
     26#set up needed files
     27firstex1 = open(file_path, 'wb')
     28spamWriter = csv.writer(firstex1)
     29spamWriter.writerow(['Time Step (s)' , 'Time Taken','Space Used'])
    2930
    3031#main loop that runs the script with different time steps (yield steps)
    3132for n in range(1,10000,10):
     33
    3234    n = n/100.0 # get it in the right range
    33 
    34     g = open(file_path_store,'r+')
    35     g.write(str(n)) #write the time step to the file
    36 
    37     x = time.clock()#time it
    38     subprocess.call(['python2.5', 'ex1.py']) # run it
    39     y = time.clock() #time it
     35    x = time.time()#time it
     36    subprocess.call(['python2.5', 'ex1.py',str(n)]) # run it
     37    y = time.time() #time it
    4038    spamWriter.writerow([n ,(y-x),'b']) #record results
    4139
    4240print 'Done'
    4341
    44 analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
     42analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
     43
     44#close ex1.csv so we can read from it for a different csv reader object
     45firstex1.close()
     46
     47#merge the metalog useful memory info and the ex1 recorded info into one csv file named final
     48ex1 = csv.reader(open(file_path,'rb'))
     49metalog = csv.reader(open(meta_path,'rb'))
     50final = csv.writer(open(final_path,'wb'))
     51
     52
     53for row in ex1:
     54    d = metalog.next()
     55    final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]])
Note: See TracChangeset for help on using the changeset viewer.