You can investigate how long something is taking using the Benchmark library.
require 'benchmark'
Benchmark.measure { some_code_I_want_to_profile }| module Lookups | |
| # Allows the definition of lookup values in a class. | |
| def define_lookup(klass_name, lookup_codes) | |
| # Ensure the classname conforms to convention | |
| klass_name = klass_name.to_s.classify | |
| # Add class methods | |
| klass = Class.new do |
| class FruitImporter | |
| include HashRemapper | |
| remaps 'fruit_name', to: :name | |
| remaps 'id', to: :fruit_store_id | |
| remaps 'coordinates', to: :coordinates_x, value: ->(c) { c[0].to_f if c} | |
| remaps 'coordinates', to: :coordinates_y, value: ->(c) { c[1].to_f if c} | |
| def import(fruit_hash) | |
| Fruit.create(remap(fruit_hash)) |
I hereby claim:
To claim this, I am signing this object:
| require 'benchmark' | |
| def f_func(x); 2*x; end | |
| def f_proc_func; proc {|x| 2*x}; end | |
| f_proc_var = proc {|x| 2*x } | |
| n = 1000000 | |
| Benchmark.bm(7) do |x| | |
| x.report("using function: ") { n.times { |i| f_func(i) } } |
| *.sol linguist-language=Solidity |
| pragma solidity ^0.5.2; | |
| pragma experimental ABIEncoderV2; | |
| import "fmg-core/contracts/Commitment.sol"; | |
| library StateActionStyle { | |
| using Commitment for Commitment.CommitmentStruct; | |
| struct StateActionAttributes { | |
| address stateActionLibrary; |
| Field | Data type | Definition / Explanation | |
|---|---|---|---|
| ChainID | unit256 | e.g. ropsten / mainnet | |
| Participants | address[] | participant addresses in signing order | |
| ChannelNonce | uint256 | chosen by the participants to uniquely identify the channel | |
| TurnNum | uint256 | turn number | |
| DefaultOutcome | [address, uint256][] | payouts if the channel is finalized in this state | |
| isFinal | boolean | used to allow instant withdrawals when channel is closed collaboratively | |
| AppDefinition | address | on-chain address of library defining custom application rules | |
| AppData | bytes | application-specific data | |
| Signature | [uint8, bytes32, bytes32] | ECDSA signature of commitment (v, r, s) |
| // in the adjudicator contract: | |
| function respond(State memory s1, State memory s2) public { | |
| // check that the first state matches the stored challenge | |
| assertHashMatches(s1, stored_challenge_hash); | |
| // framework checks | |
| assertValidSignature(s2); | |
| assertSameAppDefinition(s1, s2); | |
| assertTurnNumIncrements(s1, s2); |
| module Adjudicator { | |
| // the adjudicator explicitly declares the apps it supports | |
| import 0x32.Payments; | |
| import 0x34.Poker; | |
| // etc. | |
| public respond(adj: &mut R#Self.T, s1: &V#State, s2: &V#State) { | |
| // framework checks | |
| // … (not shown) … | |