Resolved conflict
This commit is contained in:
parent
cd39e83550
commit
cbae1775bd
@ -57,6 +57,17 @@ def run_program(program: list[str]) -> tuple[dict, str]:
|
||||
print(process.stderr)
|
||||
return (json.loads(process.stdout), process.stderr)
|
||||
|
||||
def trapezoidal_rule(power: list[float], time_s: float) -> float:
|
||||
from math import ceil
|
||||
from itertools import pairwise
|
||||
result = 0.0
|
||||
relevant_power = power[-int(time_s):]
|
||||
relevant_pairs = [pair for pair in zip(relevant_power, relevant_power[1:])]
|
||||
for pair in relevant_pairs:
|
||||
result += 0.5 * (pair[0] + pair[1])
|
||||
result += (time_s % 1) * (power[-1])
|
||||
return result
|
||||
|
||||
result = dict()
|
||||
result[Stat.CPU.name] = args.cpu.name
|
||||
result[Stat.ITERATIONS.name] = args.iterations
|
||||
@ -90,11 +101,13 @@ if args.power:
|
||||
print(result)
|
||||
|
||||
result[Stat.POWER.name] = [float(x) for x in power_process.communicate()[0].strip().split('\n')]
|
||||
# Riemann Sum across the last (s) power recordings.
|
||||
from math import ceil
|
||||
result[Stat.JOULES.name] = (
|
||||
sum(result[Stat.POWER.name][-ceil(result[Stat.TIME_S_OVERALL.name]):-1])
|
||||
+ (result[Stat.POWER.name][-1] * (result[Stat.TIME_S_OVERALL.name] % 1)))
|
||||
# Trapezoidal Rule across the last (s) power recordings.
|
||||
#result[Stat.JOULES.name] = (
|
||||
# sum(result[Stat.POWER.name][-ceil(result[Stat.TIME_S.name]):])
|
||||
# + (result[Stat.POWER.name][-1] * (result[Stat.TIME_S.name] % 1)))
|
||||
result[Stat.JOULES.name] = trapezoidal_rule(
|
||||
result[Stat.POWER.name],
|
||||
result[Stat.TIME_S.name])
|
||||
|
||||
elif args.cpu == Cpu.EPYC_7313P:
|
||||
power_process = subprocess.Popen(
|
||||
|
Loading…
Reference in New Issue
Block a user