@@ -101,7 +101,7 @@ def _use_gb_ram(num_gb):
101
101
print 'Using %.3f GB of memory over %d processors...' % (num_gb , num_procs )
102
102
for idx , proc in enumerate (proc_list ):
103
103
proc .start ()
104
- logger .debug ('Starting PID: %d' % proc .pid )
104
+ # logger.debug('Starting PID: %d' % proc.pid)
105
105
106
106
for proc in proc_list :
107
107
proc .join ()
@@ -137,12 +137,72 @@ def setUp(self):
137
137
138
138
# Init parameters
139
139
# Input RAM GB to occupy
140
- self .num_gb = .75
140
+ self .num_gb = 4
141
141
# Input number of processors
142
142
self .num_procs = 1
143
143
# Acceptable percent error for memory profiled against input
144
144
self .mem_err_percent = 5
145
145
146
+ # ! Only used for benchmarking the profiler over a range of
147
+ # ! processors and RAM usage
148
+ # ! Requires a LOT of RAM and PROCS to be tested
149
+ def _collect_range_runtime_stats (self ):
150
+ '''
151
+ Function to collect a range of runtime stats
152
+ '''
153
+
154
+ # Import packages
155
+ import json
156
+ import numpy as np
157
+ import pandas as pd
158
+
159
+ # Init variables
160
+ num_procs_range = 8
161
+ ram_gb_range = 10.0
162
+ ram_gb_step = 0.25
163
+ dict_list = []
164
+
165
+ # Iterate through all combos
166
+ for num_procs in np .arange (1 , num_procs_range + 1 , 1 ):
167
+ for num_gb in np .arange (0.25 , ram_gb_range + ram_gb_step , ram_gb_step ):
168
+ # Cmd-level
169
+ cmd_fin_str = self ._run_cmdline_workflow (num_gb , num_procs )
170
+ cmd_node_stats = json .loads (cmd_fin_str )
171
+ cmd_runtime_procs = int (cmd_node_stats ['runtime_threads' ])
172
+ cmd_runtime_gb = float (cmd_node_stats ['runtime_memory_gb' ])
173
+
174
+ # Func-level
175
+ func_fin_str = self ._run_function_workflow (num_gb , num_procs )
176
+ func_node_stats = json .loads (func_fin_str )
177
+ func_runtime_procs = int (func_node_stats ['runtime_threads' ])
178
+ func_runtime_gb = float (func_node_stats ['runtime_memory_gb' ])
179
+
180
+ # Calc errors
181
+ cmd_procs_err = cmd_runtime_procs - num_procs
182
+ cmd_gb_err = cmd_runtime_gb - num_gb
183
+ func_procs_err = func_runtime_procs - num_procs
184
+ func_gb_err = func_runtime_gb - num_gb
185
+
186
+ # Node dictionary
187
+ results_dict = {'input_procs' : num_procs ,
188
+ 'input_gb' : num_gb ,
189
+ 'cmd_runtime_procs' : cmd_runtime_procs ,
190
+ 'cmd_runtime_gb' : cmd_runtime_gb ,
191
+ 'func_runtime_procs' : func_runtime_procs ,
192
+ 'func_runtime_gb' : func_runtime_gb ,
193
+ 'cmd_procs_err' : cmd_procs_err ,
194
+ 'cmd_gb_err' : cmd_gb_err ,
195
+ 'func_procs_err' : func_procs_err ,
196
+ 'func_gb_err' : func_gb_err }
197
+ # Append to list
198
+ dict_list .append (results_dict )
199
+
200
+ # Create dataframe
201
+ runtime_results_df = pd .DataFrame (dict_list )
202
+
203
+ # Return dataframe
204
+ return runtime_results_df
205
+
146
206
# Test node
147
207
def _run_cmdline_workflow (self , num_gb , num_procs ):
148
208
'''
@@ -371,69 +431,6 @@ def test_function_profiling(self):
371
431
self .assertLessEqual (runtime_gb_err , allowed_gb_err , msg = mem_err )
372
432
self .assertEqual (num_procs , runtime_procs , msg = procs_err )
373
433
374
- # Collect stats for range of num_threads and memory amount
375
- def _collect_range_runtime_stats (self ):
376
- '''
377
- Function to collect a range of runtime stats
378
- '''
379
-
380
- # Import packages
381
- import json
382
- import numpy as np
383
- import pandas as pd
384
-
385
- # Init variables
386
- num_procs_range = 8
387
- ram_gb_range = 10.0
388
- ram_gb_step = 0.25
389
- dict_list = []
390
-
391
- # Iterate through all combos
392
- for num_procs in np .arange (1 , num_procs_range + 1 , 1 ):
393
- for num_gb in np .arange (0.25 , ram_gb_range + ram_gb_step , ram_gb_step ):
394
- # Cmd-level
395
- cmd_fin_str = self ._run_cmdline_workflow (num_gb , num_procs )
396
- cmd_node_stats = json .loads (cmd_fin_str )
397
- cmd_runtime_procs = int (cmd_node_stats ['runtime_threads' ])
398
- cmd_runtime_gb = float (cmd_node_stats ['runtime_memory_gb' ])
399
-
400
- # Func-level
401
- func_fin_str = self ._run_function_workflow (num_gb , num_procs )
402
- func_node_stats = json .loads (func_fin_str )
403
- func_runtime_procs = int (func_node_stats ['runtime_threads' ])
404
- func_runtime_gb = float (func_node_stats ['runtime_memory_gb' ])
405
-
406
- # Calc errors
407
- cmd_procs_err = cmd_runtime_procs - num_procs
408
- cmd_gb_err = cmd_runtime_gb - num_gb
409
- func_procs_err = func_runtime_procs - num_procs
410
- func_gb_err = func_runtime_gb - num_gb
411
-
412
- # Node dictionary
413
- results_dict = {'input_procs' : num_procs ,
414
- 'input_gb' : num_gb ,
415
- 'cmd_runtime_procs' : cmd_runtime_procs ,
416
- 'cmd_runtime_gb' : cmd_runtime_gb ,
417
- 'func_runtime_procs' : func_runtime_procs ,
418
- 'func_runtime_gb' : func_runtime_gb ,
419
- 'cmd_procs_err' : cmd_procs_err ,
420
- 'cmd_gb_err' : cmd_gb_err ,
421
- 'func_procs_err' : func_procs_err ,
422
- 'func_gb_err' : func_gb_err }
423
- # Append to list
424
- dict_list .append (results_dict )
425
-
426
- # Create dataframe
427
- runtime_results_df = pd .DataFrame (dict_list )
428
-
429
- # Return dataframe
430
- return runtime_results_df
431
-
432
- def test_write_df_to_csv (self ):
433
- df = self ._collect_range_runtime_stats ()
434
- df .to_csv ('/home/dclark/runtime_results.csv' )
435
- #self.assertEqual(1, 1)
436
-
437
434
438
435
# Command-line run-able unittest module
439
436
if __name__ == '__main__' :
0 commit comments