Skip to content

Commit

Permalink
Update babeltrace_thapi.in
Browse files Browse the repository at this point in the history
  • Loading branch information
TApplencourt authored Sep 11, 2023
1 parent a3339d9 commit f9b66d2
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions utils/babeltrace_thapi.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,20 @@ def get_components(names)
require 'babeltrace_cuda_lib' if $options[:backends].include?('cuda')
require 'babeltrace_hip_lib' if $options[:backends].include?('hip')
# I guess need to put it in `babeltrace_energy_lib` at some point?
$energies={}
$event_lambdas["lttng_ust_ze_sampling:gpu_energy"] = lambda { |defi|
energy = defi['energy']
timestamp = defi['timestamp']
key = [ defi['hDevice'], defi['domain'] ]
previous = $energies[key]
if previous
p_energy, p_timestamp = previous
puts "#{key[0]}:#{key[1]}: #{(energy - p_energy).to_f/(timestamp - p_timestamp)}"
end
$energies[key] = [energy, timestamp]
} if $options[:backends].include?('ze')
if $options[:backends].include?('ze')
$energies={}
$event_lambdas["lttng_ust_ze_sampling:gpu_energy"] = lambda { |defi|
energy = defi['energy']
timestamp = defi['timestamp']
key = [ defi['hDevice'], defi['domain'] ]
previous = $energies[key]
if previous
p_energy, p_timestamp = previous
puts "#{key[0]}:#{key[1]}: #{(energy - p_energy).to_f/(timestamp - p_timestamp)}"
end
$energies[key] = [energy, timestamp]
}
end

f = lambda { |iterator, _|
iterator.next_messages.each do |m|
Expand Down

0 comments on commit f9b66d2

Please sign in to comment.