Changeset 8326 for trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py
- Timestamp:
- Jan 31, 2012, 10:54:12 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/parameters/timelen-over-timestep/main.py
r8315 r8326 1 """Simple water flow example using ANUGA2 Water flowing down a channel3 """4 1 #------------------------------------------------------------------------------ 5 2 # Import necessary modules … … 10 7 import random 11 8 import subprocess 12 import ex113 9 import csv 14 10 import os 15 from anuga.utilities import system_tools, log16 11 from anuga.abstract_2d_finite_volumes.util import add_directories 17 #------------------------------------------------------------------------------ 18 # Setup computational domain 19 #------------------------------------------------------------------------------ 20 a = [] 21 home = os.getenv('INUNDATIONHOME') 12 from anuga.utilities.log_analyser import analyse_log 22 13 23 14 15 #------------------------------------------------------------------------------ 16 # Set up variables for the correct directories to store the output 17 #------------------------------------------------------------------------------ 18 home = os.getenv('INUNDATIONHOME') 24 19 scenariodir = add_directories(home, ["data","mem_time_test", "parameters", 25 20 "timelen-over-timestep"]) 26 21 file = 'ex1.csv' 22 file_path = os.path.join(scenariodir, file) 23 spamWriter = csv.writer(open(file_path, 'wb')) 24 spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used']) 25 store ='store.txt' 26 file_path_store = os.path.join(scenariodir, store) 27 storen ='storen.txt' 28 file_path_storen = os.path.join(scenariodir, storen) 27 29 28 log.log_filename = os.path.join(scenariodir, 'log.txt') 30 #create each file 31 e = open(file_path_store,'a') 32 e.close() 33 e = open(file_path_storen,'a') 34 e.close() 29 35 30 file_path = os.path.join(scenariodir, file)31 36 32 spamWriter = csv.writer(open(file_path, 'wb'))33 37 34 spamWriter.writerow(['Time Length', 'Time Step' , 'Time Taken','Space Used']) 35 38 # main loops that give the time length (m) and the time step (n) 36 39 for m in range(1,1000,50): 37 40 38 41 for n in range(1,1000,5): 39 n = n/1000.0 40 system_tools.MemoryUpdate() 41 x = time.clock() 42 ex1.runex(float(m),n) 43 y = time.clock() 44 b = system_tools.MemoryUpdate()[0] 45 spamWriter.writerow([m,n ,(y-x),b]) 46 a.append((n,y-x,b)) 47 print a 42 n = n/1000.0 #adjust it so its small enough to see the nature of the relationship 48 43 44 #write to file 45 s = open(file_path_store,'r+') 46 s.write(str(float(m))) 47 t = open(file_path_storen,'r+') 48 t.write(str(n)) 49 50 x = time.clock()#time it 51 subprocess.call(['python2.5', 'ex1.py'])#run it 52 y = time.clock()#time it 53 spamWriter.writerow([m,n ,(y-x),'b'])#write the results 54 55 print 'Done' 56 57 analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the log files
Note: See TracChangeset
for help on using the changeset viewer.