diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-09 02:18:32 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-06-09 05:56:45 +0800 |
commit | 760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36 (patch) | |
tree | 05911f7eaa9cd8a48448b371f46186d2ffc5541e /packages/contracts/src/utils/profiler.ts | |
parent | 817c332d11835f02726f0609374d1c25c9ab39b5 (diff) | |
download | dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.gz dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.bz2 dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.lz dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.xz dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.tar.zst dexon-sol-tools-760bab8f866ec3d5fc7627ce9bbf5c2eaaef1f36.zip |
Implement SolidityProfiler & adapt sol-cov to work with Geth
Diffstat (limited to 'packages/contracts/src/utils/profiler.ts')
-rw-r--r-- | packages/contracts/src/utils/profiler.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/profiler.ts b/packages/contracts/src/utils/profiler.ts new file mode 100644 index 000000000..85ee24f22 --- /dev/null +++ b/packages/contracts/src/utils/profiler.ts @@ -0,0 +1,27 @@ +import { devConstants } from '@0xproject/dev-utils'; +import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0xproject/sol-cov'; +import * as _ from 'lodash'; + +let profilerSubprovider: ProfilerSubprovider; + +export const profiler = { + start(): void { + profiler.getProfilerSubproviderSingleton().start(); + }, + stop(): void { + profiler.getProfilerSubproviderSingleton().stop(); + }, + getProfilerSubproviderSingleton(): ProfilerSubprovider { + if (_.isUndefined(profilerSubprovider)) { + profilerSubprovider = profiler._getProfilerSubprovider(); + } + return profilerSubprovider; + }, + _getProfilerSubprovider(): ProfilerSubprovider { + const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS; + const solCompilerArtifactAdapter = new SolCompilerArtifactAdapter(); + const isVerbose = true; + const subprovider = new ProfilerSubprovider(solCompilerArtifactAdapter, defaultFromAddress, isVerbose); + return subprovider; + }, +}; |