Class: Pwrake::TaskStat
- Inherits:
-
Object
- Object
- Pwrake::TaskStat
- Defined in:
- lib/pwrake/report/task_stat.rb
Instance Attribute Summary collapse
-
#exec_hosts ⇒ Object
readonly
Returns the value of attribute exec_hosts.
-
#ncore ⇒ Object
readonly
Returns the value of attribute ncore.
Instance Method Summary collapse
- #[](exec_host, loc, key) ⇒ Object
- #count(exec_host, loc, key, val) ⇒ Object
-
#initialize(task_file, sh_table) ⇒ TaskStat
constructor
A new instance of TaskStat.
- #stat_sh_table(sh_table) ⇒ Object
- #task_locality ⇒ Object
- #total(loc, key) ⇒ Object
Constructor Details
#initialize(task_file, sh_table) ⇒ TaskStat
Returns a new instance of TaskStat.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pwrake/report/task_stat.rb', line 5 def initialize(task_file, sh_table) begin @task_table = CSV.read(task_file,:headers=>true,:skip_lines=>/\A#/) rescue $stderr.puts "error in reading "+task_file $stderr.puts $!, $@ exit end shell_id = {} @task_table.each do |row| if id=row['shell_id'] shell_id[[row['exec_host'],id].join(":")] = true end end @ncore = shell_id.size @count = Hash.new(0) task_locality stat_sh_table(sh_table) end |
Instance Attribute Details
#exec_hosts ⇒ Object (readonly)
Returns the value of attribute exec_hosts.
25 26 27 |
# File 'lib/pwrake/report/task_stat.rb', line 25 def exec_hosts @exec_hosts end |
#ncore ⇒ Object (readonly)
Returns the value of attribute ncore.
25 26 27 |
# File 'lib/pwrake/report/task_stat.rb', line 25 def ncore @ncore end |
Instance Method Details
#[](exec_host, loc, key) ⇒ Object
36 37 38 |
# File 'lib/pwrake/report/task_stat.rb', line 36 def [](exec_host,loc,key) @count[[exec_host,loc,key]] end |
#count(exec_host, loc, key, val) ⇒ Object
27 28 29 30 |
# File 'lib/pwrake/report/task_stat.rb', line 27 def count(exec_host, loc, key, val) @count[[exec_host,loc,key]] += val @count[[loc,key]] += val end |
#stat_sh_table(sh_table) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/pwrake/report/task_stat.rb', line 73 def stat_sh_table(sh_table) sh_table.each do |row| if (h = row['host']) && (t = row['elap_time']) count(h, nil, :elap, t.to_f) end end end |
#task_locality ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pwrake/report/task_stat.rb', line 40 def task_locality file_size = {} h = {} @task_table.each do |row| name = row['task_name'] file_size[name] = row['file_size'].to_i exec_host = row['exec_host'] || "" h[exec_host] = true end @exec_hosts = h.keys.sort @task_table.each do |row| if row['executed']=='1' name = row['task_name'] exec_host = row['exec_host'] loc = (row['write_loc'] == "L") count(exec_host, loc, :out_num, 1) count(exec_host, loc, :out_size, file_size[name]) preq_files = (row['preq']||'').split('|') preq_loc = row['preq_loc']||'' preq_files.each_with_index do |preq,i| sz = file_size[preq] if sz && sz > 0 loc = (preq_loc[i] == "L") count(exec_host, loc, :in_num, 1) count(exec_host, loc, :in_size, sz) end end end end end |
#total(loc, key) ⇒ Object
32 33 34 |
# File 'lib/pwrake/report/task_stat.rb', line 32 def total(loc,key) @count[[loc,key]] end |