Normalize statistics about compilation time and allocation size.

Now we print compilation time and zone allocation per KB of compiled
source code to better compare with previous revisions.

Review URL: http://codereview.chromium.org/6646015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7128 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a7bfc328
......@@ -248,7 +248,7 @@ static bool MakeCrankshaftCode(CompilationInfo* info) {
// performance of the hydrogen-based compiler.
int64_t start = OS::Ticks();
bool should_recompile = !info->shared_info()->has_deoptimization_support();
if (should_recompile || FLAG_time_hydrogen) {
if (should_recompile || FLAG_hydrogen_stats) {
HPhase phase(HPhase::kFullCodeGen);
CompilationInfo unoptimized(info->shared_info());
// Note that we use the same AST that we will use for generating the
......
......@@ -111,7 +111,7 @@ DEFINE_bool(use_inlining, true, "use function inlining")
DEFINE_bool(limit_inlining, true, "limit code size growth from inlining")
DEFINE_bool(eliminate_empty_blocks, true, "eliminate empty blocks")
DEFINE_bool(loop_invariant_code_motion, true, "loop invariant code motion")
DEFINE_bool(time_hydrogen, false, "timing for hydrogen")
DEFINE_bool(hydrogen_stats, false, "print statistics for hydrogen")
DEFINE_bool(trace_hydrogen, false, "trace generated hydrogen to file")
DEFINE_bool(trace_inlining, false, "trace inlining decisions")
DEFINE_bool(trace_alloc, false, "trace register allocator")
......
......@@ -2134,6 +2134,8 @@ void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
HGraph* HGraphBuilder::CreateGraph() {
graph_ = new HGraph(info());
if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
{
HPhase phase("Block building");
current_block_ = graph()->entry_block();
......@@ -5810,6 +5812,11 @@ void HTracer::FlushToFile() {
}
void HStatistics::Initialize(CompilationInfo* info) {
source_size_ += info->shared_info()->SourceSize();
}
void HStatistics::Print() {
PrintF("Timing results:\n");
int64_t sum = 0;
......@@ -5827,9 +5834,10 @@ void HStatistics::Print() {
double size_percent = static_cast<double>(size) * 100 / total_size_;
PrintF(" %8u bytes / %4.1f %%\n", size, size_percent);
}
PrintF("%30s - %7.3f ms %8u bytes\n", "Sum",
static_cast<double>(sum) / 1000,
total_size_);
double source_size_in_kb = static_cast<double>(source_size_) / 1024;
PrintF("%30s - %7.3f ms %7.3f bytes\n", "Sum",
(static_cast<double>(sum) / 1000) / source_size_in_kb,
total_size_ / source_size_in_kb);
PrintF("---------------------------------------------------------------\n");
PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n",
"Total",
......@@ -5874,13 +5882,13 @@ void HPhase::Begin(const char* name,
if (allocator != NULL && chunk_ == NULL) {
chunk_ = allocator->chunk();
}
if (FLAG_time_hydrogen) start_ = OS::Ticks();
if (FLAG_hydrogen_stats) start_ = OS::Ticks();
start_allocation_size_ = Zone::allocation_size_;
}
void HPhase::End() const {
if (FLAG_time_hydrogen) {
if (FLAG_hydrogen_stats) {
int64_t end = OS::Ticks();
unsigned size = Zone::allocation_size_ - start_allocation_size_;
HStatistics::Instance()->SaveTiming(name_, end - start_, size);
......
......@@ -939,6 +939,7 @@ class HValueMap: public ZoneObject {
class HStatistics: public Malloced {
public:
void Initialize(CompilationInfo* info);
void Print();
void SaveTiming(const char* name, int64_t ticks, unsigned size);
static HStatistics* Instance() {
......@@ -957,7 +958,8 @@ class HStatistics: public Malloced {
sizes_(5),
total_(0),
total_size_(0),
full_code_gen_(0) { }
full_code_gen_(0),
source_size_(0) { }
List<int64_t> timing_;
List<const char*> names_;
......@@ -965,6 +967,7 @@ class HStatistics: public Malloced {
int64_t total_;
unsigned total_size_;
int64_t full_code_gen_;
double source_size_;
};
......
......@@ -158,7 +158,7 @@ void V8::SetFatalError() {
void V8::TearDown() {
if (!has_been_setup_ || has_been_disposed_) return;
if (FLAG_time_hydrogen) HStatistics::Instance()->Print();
if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
// We must stop the logger before we tear down other components.
Logger::EnsureTickerStopped();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment