Commit 5d292f9f by Sridutt Bhalachandra

### [refactor] Diff calculation without coolr changes

```Refactored diff calculation code to work without needing changes in
coolr module (Patch for Commit 36401a84)```
parent 95188157
 ... ... @@ -142,12 +142,10 @@ class rapl_reader: ret[k] = dvals return ret def diffenergy(self,e1,e2,shortenFlag=False): # e1 is prev and e2 is not def diffenergy(self,e1,e2): # e1 is prev and e2 is not ret = {} ret['time'] = e2['time'] - e1['time'] for k in self.max_energy_range_uj_d: if shortenFlag: k = self.shortenkey(k) if e2[k]>=e1[k]: ret[k] = e2[k] - e1[k] else: ... ... @@ -157,7 +155,7 @@ class rapl_reader: # calculate the average power from two energy values # e1 and e2 are the value returned from readenergy() # e1 should be sampled before e2 def calcpower(self,e1,e2,shortenFlag=False): def calcpower(self,e1,e2): ret = {} delta = e2['time'] - e1['time'] # assume 'time' never wrap around ret['delta'] = delta ... ... @@ -168,8 +166,6 @@ class rapl_reader: return ret for k in self.max_energy_range_uj_d: if shortenFlag: k = self.shortenkey(k) if e2[k]>=e1[k]: ret[k] = e2[k] - e1[k] else: ... ...
 ... ... @@ -47,8 +47,15 @@ class SensorManager: def calc_difference(self, start, end): diff = dict() for k in start.keys(): if k not in ['time']: start[k.replace('p', 'package-')] = start[k] start.pop(k) end[k.replace('p', 'package-')] = end[k] end.pop(k) # Calculate energy difference diff['energy'] = self.rapl.diffenergy(start, end, shortenFlag=True) diff['energy'] = self.rapl.diffenergy(start, end) # Update time elapsed diff['time'] = diff['energy']['time'] # Remove 'time' field returned by function ... ... @@ -58,7 +65,7 @@ class SensorManager: diff['energy']} # Calculate power difference diff['power'] = self.rapl.calcpower(start, end, shortenFlag=True) diff['power'] = self.rapl.calcpower(start, end) # Remove 'delta' field returned by function diff['power'].pop('delta') ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment