source: trunk/anuga_work/development/mem_time_tests/triangles/fromregions/main.py @ 8328

Last change on this file since 8328 was 8328, checked in by pittj, 12 years ago

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

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities.log_analyser import analyse_log
11
12#------------------------------------------------------------------------------
13# Set up variables for the correct directories to store the output
14#------------------------------------------------------------------------------
15home = os.getenv('INUNDATIONHOME')
16scenariodir = add_directories(home, ["data","mem_time_test", "triangles",
17                                     "fromregions"])
18storea ='storea.txt'
19file_path_storea = os.path.join(scenariodir, storea)
20meta = 'metalog.csv'
21meta_path = os.path.join(scenariodir, meta)
22final = 'final.csv'
23final_path = os.path.join(scenariodir, final)
24file = 'ex1.csv'
25file_path = os.path.join(scenariodir, file)
26
27#create and set up the files
28firstex1 = open(file_path, 'wb')
29spamWriter = csv.writer(firstex1)
30spamWriter.writerow(['Number Of Triangles','Maximum Area(m^2)','Extent(m^2)' , 'Time Taken(s)','Space Used'])
31e = open(file_path_storea,'a')
32e.close()
33
34#these are the main loops that determine the maximum triangle area (m) and the map side length(n)
35for m in range(20,1000,50):
36    for n in range(1,100000,10000):
37
38        z = time.time() #time it
39        subprocess.call(['python2.5', 'runcairns.py',str(m),str(n)])#run simulation
40        y = time.time() #time it
41
42        #read the number of triangles from this text file
43        f = open(file_path_storea,'r+')
44        h = float(f.readline())
45        f.close()
46
47        spamWriter.writerow([h,m,(n*n),'x' ,(y-z)]) #record it
48print 'DONE'
49
50analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
51
52#close ex1.csv so we can read from it for a different csv reader object
53firstex1.close()
54
55#merge the metalog useful memory info and the ex1 recorded info into one csv file named final
56ex1 = csv.reader(open(file_path,'rb'))
57metalog = csv.reader(open(meta_path,'rb'))
58final = csv.writer(open(final_path,'wb'))
59
60
61for row in ex1:
62    d = metalog.next()
63    final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]])
Note: See TracBrowser for help on using the repository browser.