npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scenario-eth-gas-reporter

v0.0.1

Published

Mocha reporter which show gas used by different implement variants for a scenario (based on eth-gas-reporter)

Downloads

3

Readme

scenario-eth-gas-reporter

This project was done as master thesis at the University of Duisburg-Essen Germany with the title "Engineering an Analysis Tool for Comparing Transaction Costs in Ethereum Smart Contracts"

A Mocha reporter for Ethereum test suites: Detailed information of gas usage per test case. One test case represent a implement variant of a given scenario. See more Information here. A mocha reporter based on eth-gas-reporter.

  • Detailed information about metrics for method calls and deployments within one test case
  • Test case represents a implement variant of a given scenario
  • Implement variants will be grouped within a scenario
  • Possible to analyze and compare gas cost of multiple smarct contracts
  • Simple installation for Truffle

Example output

Example Output

Installation and Config

Truffle

npm install --save-dev scenario-eth-gas-reporter
/* truffle-config.js */
module.exports = {
  networks: { ... },
  mocha: {
    reporter: 'scenario-eth-gas-reporter',
    reporterOptions : { ... } // See options below
  }
};

Other

This reporter should work with any build platform that uses Mocha and connects to an Ethereum client running as a separate process. There's more on advanced use cases here.

Options

| Option | Type | Default | Description | |------------------|------------------------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| | noColors | _Boolean | false | | | excludeContracts | String[] | [migrations] | Contract names to exclude from report. Ex: ['Migrations'] | | src | String | "contracts" | Folder in root directory to begin search for .sol files. This can also be a path to a subfolder relative to the root, e.g. "planets/annares/contracts" | | proxyResolver | Function | none | Custom method to resolve identity of methods managed by a proxy contract | | artifactType | Function or String | "truffle-v5" | Compilation artifact format to consume. (See advanced use.) |

Usage Notes

  • Requires Node >= 8.
  • You cannot use ganache-core as an in-process provider for your test suite. The reporter makes sync RPC calls while collecting data and your tests will hang unless the client is launched as a separate process.
  • Method calls that throw are filtered from the stats.
  • Contracts that are only ever created by other contracts within Solidity are not shown in the deployments table.

Usage Details

  • Name of contract-block represents a implement variant, which will be mapped to the name of the it-block (name of it-block represent a scenario): -In the given example we got two scenarios (Parity Numbers Scenario and Non-parity Number Scenario) with two implement variants each (Parity Binary and Parity Modulo)
/* example test.js */
contract("Parity_Binary", async accounts => {
  it("Parity Numbers Scenario", async () => {
    const binary = await Binary.new();
    const parity = await binary.checkParity(10, 20);
  });
});

contract("Parity_Modulo", async accounts => {
  it("Parity Numbers Scenario", async () => {
    const modulo = await Modulo.new();
    const parity = await modulo.checkParity(10, 20);
  });
});

contract("Parity_Binary", async accounts => {
  it("Non-Parity Numbers Scenario", async () => {
    const binary = await Binary.new();
    const parity = await binary.checkParity(10, 5);
  });
});

contract("Parity_Modulo", async accounts => {
  it("Non-Parity Numbers Scenario", async () => {
    const modulo = await Modulo.new();
    const parity = await modulo.checkParity(10, 5);
  });
});

Gas Reporter JSON output

The gas reporter writes the data it collects to a JSON file at ./scenario-gas-reports/dateofcreation.json. An example of this output is here. You may find it useful as an input to more complex / long running gas analyses, etc.. Feel free to open an Issue if critical information for your analyses are missing from the json.

Credits

All the ideas in this utility have been borrowed from elsewhere. Many thanks to:

  • [@coldDevil] supervisor of master thesis
  • @cgewecke - Publisher of eth-gas-reporter, which is used within the core of this tool
  • All further Contributors and Creditors of eth-gas-reporter