mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Print compilation/execution times
This commit is contained in:
parent
a60843e622
commit
a90ebe63dc
2 changed files with 23 additions and 0 deletions
|
|
@ -10,6 +10,9 @@
|
|||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/IntrinsicInst.h>
|
||||
|
||||
#include <llvm/PassManager.h>
|
||||
#include <llvm/Transforms/Scalar.h>
|
||||
|
||||
#include <libevmface/Instruction.h>
|
||||
|
||||
#include "Type.h"
|
||||
|
|
@ -264,6 +267,11 @@ std::unique_ptr<llvm::Module> Compiler::compile(bytesConstRef bytecode)
|
|||
dump();
|
||||
}
|
||||
|
||||
llvm::FunctionPassManager fpManager(module.get());
|
||||
fpManager.add(llvm::createLowerSwitchPass());
|
||||
fpManager.doInitialization();
|
||||
fpManager.run(*m_mainFunc);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "ExecutionEngine.h"
|
||||
|
||||
#include <csetjmp>
|
||||
#include <chrono>
|
||||
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
|
|
@ -72,7 +73,13 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
|
|||
if (!exec)
|
||||
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment(errorMsg));
|
||||
_module.release(); // Successfully created llvm::ExecutionEngine takes ownership of the module
|
||||
|
||||
auto finalizationStartTime = std::chrono::high_resolution_clock::now();
|
||||
exec->finalizeObject();
|
||||
auto finalizationEndTime = std::chrono::high_resolution_clock::now();
|
||||
std::cerr << "*** Module finalization time: "
|
||||
<< std::chrono::duration_cast<std::chrono::microseconds>(finalizationEndTime - finalizationStartTime).count()
|
||||
<< std::endl;
|
||||
|
||||
// Create fake ExtVM interface
|
||||
if (!_ext)
|
||||
|
|
@ -107,9 +114,17 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtV
|
|||
auto r = setjmp(buf);
|
||||
if (r == 0)
|
||||
{
|
||||
auto executionStartTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
rt_jmpBuf = &buf;
|
||||
auto result = exec->runFunction(entryFunc, {});
|
||||
returnCode = static_cast<ReturnCode>(result.IntVal.getZExtValue());
|
||||
|
||||
auto executionEndTime = std::chrono::high_resolution_clock::now();
|
||||
std::cerr << "*** Execution time: "
|
||||
<< std::chrono::duration_cast<std::chrono::microseconds>(executionEndTime - executionStartTime).count()
|
||||
<< std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
returnCode = static_cast<ReturnCode>(r);
|
||||
|
|
|
|||
Loading…
Reference in a new issue