Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/counters.cc

Issue 2342643004: [Tracing] Remove unnecessary memory allocation in runtime call stats. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/counters.h ('k') | src/tracing/trace-event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/counters.h" 5 #include "src/counters.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 8
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 FOR_EACH_API_COUNTER(RESET_COUNTER) 357 FOR_EACH_API_COUNTER(RESET_COUNTER)
358 #undef RESET_COUNTER 358 #undef RESET_COUNTER
359 359
360 #define RESET_COUNTER(name) this->Handler_##name.Reset(); 360 #define RESET_COUNTER(name) this->Handler_##name.Reset();
361 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER) 361 FOR_EACH_HANDLER_COUNTER(RESET_COUNTER)
362 #undef RESET_COUNTER 362 #undef RESET_COUNTER
363 363
364 in_use_ = true; 364 in_use_ = true;
365 } 365 }
366 366
367 const char* RuntimeCallStats::Dump() { 367 std::string RuntimeCallStats::Dump() {
368 buffer_.str(std::string()); 368 buffer_.str(std::string());
369 buffer_.clear(); 369 buffer_.clear();
370 buffer_ << "{"; 370 buffer_ << "{";
371 #define DUMP_COUNTER(name) \ 371 #define DUMP_COUNTER(name) \
372 if (this->name.count > 0) this->name.Dump(buffer_); 372 if (this->name.count > 0) this->name.Dump(buffer_);
373 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER) 373 FOR_EACH_MANUAL_COUNTER(DUMP_COUNTER)
374 #undef DUMP_COUNTER 374 #undef DUMP_COUNTER
375 375
376 #define DUMP_COUNTER(name, nargs, result_size) \ 376 #define DUMP_COUNTER(name, nargs, result_size) \
377 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_); 377 if (this->Runtime_##name.count > 0) this->Runtime_##name.Dump(buffer_);
378 FOR_EACH_INTRINSIC(DUMP_COUNTER) 378 FOR_EACH_INTRINSIC(DUMP_COUNTER)
379 #undef DUMP_COUNTER 379 #undef DUMP_COUNTER
380 380
381 #define DUMP_COUNTER(name) \ 381 #define DUMP_COUNTER(name) \
382 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_); 382 if (this->Builtin_##name.count > 0) this->Builtin_##name.Dump(buffer_);
383 BUILTIN_LIST_C(DUMP_COUNTER) 383 BUILTIN_LIST_C(DUMP_COUNTER)
384 #undef DUMP_COUNTER 384 #undef DUMP_COUNTER
385 385
386 #define DUMP_COUNTER(name) \ 386 #define DUMP_COUNTER(name) \
387 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); 387 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_);
388 FOR_EACH_API_COUNTER(DUMP_COUNTER) 388 FOR_EACH_API_COUNTER(DUMP_COUNTER)
389 #undef DUMP_COUNTER 389 #undef DUMP_COUNTER
390 390
391 #define DUMP_COUNTER(name) \ 391 #define DUMP_COUNTER(name) \
392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); 392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_);
393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) 393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
394 #undef DUMP_COUNTER 394 #undef DUMP_COUNTER
395 buffer_ << "\"END\":[]}"; 395 buffer_ << "\"END\":[]}";
396 const std::string& buffer_str = buffer_.str();
397 size_t length = buffer_str.size();
398 if (length > len_) {
399 buffer_c_str_.reset(new char[length + 1]);
400 len_ = length;
401 }
402 strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1);
403 in_use_ = false; 396 in_use_ = false;
404 return buffer_c_str_.get(); 397 return buffer_.str();
405 } 398 }
406 399
407 } // namespace internal 400 } // namespace internal
408 } // namespace v8 401 } // namespace v8
OLDNEW
« no previous file with comments | « src/counters.h ('k') | src/tracing/trace-event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698