Skip to content

Commit

Permalink
Merge child gas stats into parent gas stats
Browse files Browse the repository at this point in the history
  • Loading branch information
cag committed Mar 2, 2018
1 parent 5857c66 commit ce1d68f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/measure_gas_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ spawnSync('npm', ['test'], { stdio: 'inherit', env: newEnv })

const gasStats = JSON.parse(fs.readFileSync(gasStatsFile))

// make sure this is toposorted
const inheritanceMap = [
['Event', ['CategoricalEvent', 'ScalarEvent']],
['StandardMarket', ['StandardMarketWithPriceLogger']],
['Market', ['StandardMarket']],
['MarketMaker', ['LMSRMarketMaker']],
['Oracle', ['CentralizedOracle', 'DifficultyOracle', 'FutarchyOracle', 'MajorityOracle', 'SignedMessageOracle', 'UltimateOracle']],
['StandardToken', ['EtherToken', 'OutcomeToken']],
['Token', ['StandardToken']],
].forEach(([parent, children]) => {
const childrenData = children.map(name => gasStats[name]).filter(data => data)
if(childrenData.length === 0) return
if(!gasStats[parent])
gasStats[parent] = {}

_.mergeWith(gasStats[parent], ...childrenData, (objValue, srcValue) =>
_.isArray(objValue) ? objValue.concat(srcValue) : undefined)
})

console.log('-- Gas stats --')

_.forEach(gasStats, (contractData, contractName) => {
Expand Down

0 comments on commit ce1d68f

Please sign in to comment.