Skip to content

Commit 689598d

Browse files
committed
power consumption display values, interaction fix when selecting scaling option + changing hardware
1 parent c0d7693 commit 689598d

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

frontend/src/partials/BenchmarkSettings.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ function BenchmarkSettings() {
107107
const scaledUtilization = clamp( currentServer.utilization as number * ratio, 0, 100);
108108
updateServer(newServer, { utilization: scaledUtilization });
109109
}
110-
}, [scaling])
110+
111+
if (scaling === "Emissions") {
112+
updateServer(newServer, { utilization: currentServer.utilization });
113+
}
114+
115+
if (scaling === "None") {
116+
updateServer(newServer, { utilization: currentServer.utilization });
117+
}
118+
119+
}, [scaling, currentServer, newServer])
111120

112121
return (
113122
<div className="flex z-30 flex-col text-medium font-medium flex-wrap px-4 py-2 gap-4">

frontend/src/partials/Compare.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,16 @@ const Dropdown: React.FC<DropdownProps> = ({ label, thisServer, otherServer, sho
248248
<table className="text-base grow border-collapse">
249249
<tbody>
250250
{Object.entries(DISPLAY).map(([key, prop]) => {
251-
let selectedValue = specs_selected[prop] || 0;
251+
const selectedValue = specs_selected[prop] || 0;
252252
const compareValue = (specs_compareTo?.[prop] ?? selectedValue) || 0;
253-
if (key == 'TDP') selectedValue = selectedValue + ' W';
253+
254+
const selectedFormatted = selectedValue + (key == 'TDP' ? ' W' : '');
255+
254256
return (
255257
<tr key={key}>
256258
<td className="w-0 pr-4 align-top text-left">{key}:</td>
257259
<td className="flex items-center gap-1">
258-
<p>{selectedValue}</p>
260+
<p>{selectedFormatted}</p>
259261
{selectedValue > compareValue && !singleComparison && (
260262
<img src={UP_ARROW} className="h-full" alt="up" />
261263
)}

frontend/src/partials/DetailedBreakdown.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const BreakdownCard: React.FC<BreakdownCardProp> = ({ title, breakdown, borderCo
105105
};
106106

107107
function DetailedBreakdown() {
108-
const { currentServer, newServer, comparison, intersect, workload, singleComparison, oldPerformanceIndicator, newPerformanceIndicator, capexBreakdown, opexBreakdown, oldPowerConsumption, newPowerConsumption } = useBenchmarkContext();
108+
const { currentServer, newServer, comparison, intersect, workload, singleComparison, oldPerformanceIndicator, newPerformanceIndicator, scaling, capexBreakdown, opexBreakdown, oldPowerConsumption, newPowerConsumption } = useBenchmarkContext();
109109

110110
const year = intersect ? yearToYearAndMonth(Number(intersect.x.toFixed(1)), false, true) : "No Break-Even";
111111
const total = intersect ? addCommaToNumber(Number(intersect.y.toFixed(1))) + " kgCO₂" : "No Break-even";
@@ -116,15 +116,21 @@ function DetailedBreakdown() {
116116
const titleText = singleComparison ? 'Current' : 'New'
117117

118118
let perfRatio :any = (newPerformanceIndicator / oldPerformanceIndicator)
119-
let consumptionRatio :any = (newPowerConsumption / oldPowerConsumption)
119+
let normalizedOldPowerConsumption = oldPowerConsumption;
120+
121+
if (scaling === 'Emissions') {
122+
normalizedOldPowerConsumption = oldPowerConsumption * perfRatio;
123+
}
124+
125+
let consumptionRatio :any = (newPowerConsumption / normalizedOldPowerConsumption)
120126

121127
const ratioDecimalPlaces = withinXPercent(perfRatio, consumptionRatio, 0.1) ? 3 : 1;
122128
perfRatio = perfRatio.toFixed(ratioDecimalPlaces).replace(/\.000$/, '');
123129
consumptionRatio = consumptionRatio.toFixed(ratioDecimalPlaces).replace(/\.000$/, '');
124130

125131
let oldPerfFormatted = oldPerformanceIndicator.toFixed(1).replace(/\.0$/, '');
126132
let newPerfFormatted = newPerformanceIndicator.toFixed(1).replace(/\.0$/, '');
127-
let oldConsumptionFormatted = oldPowerConsumption.toFixed(3).replace(/\.0$/, '');
133+
let oldConsumptionFormatted = normalizedOldPowerConsumption.toFixed(3).replace(/\.0$/, '');
128134
let newConsumptionFormatted = newPowerConsumption.toFixed(3).replace(/\.0$/, '');
129135

130136
newPerfFormatted = addCommaToNumber(Number(newPerfFormatted));

0 commit comments

Comments
 (0)