citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit ae77b59d403184aef5f813072071df3e512bf04f
parent d9778150fe21e667449c54a27fab628bd520ed5b
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 29 Jul 2016 21:42:42 -0600

src: add new has_execs struct field

Diffstat:
Msrc/runtime.cc | 5++---
Msrc/runtime.hh | 1+
Msrc/term_main.cc | 14+++++++++-----
3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/runtime.cc b/src/runtime.cc @@ -74,10 +74,9 @@ void RuntimeProcess::read_executions() { for (auto &t : m_tus) { - uint8_t flag = 0; - m_socket.read_all(flag); + m_socket.read_all(t.has_execs); - if (flag == 0) { + if (t.has_execs == 0) { std::fill(t.exec_diffs.begin(), t.exec_diffs.end(), 0); continue; } diff --git a/src/runtime.hh b/src/runtime.hh @@ -9,6 +9,7 @@ struct TranslationUnit { std::string file_name; uint32_t num_lines; uint32_t inst_sites; + uint8_t has_execs; std::vector<uint32_t> exec_diffs; std::vector<std::string> source; }; diff --git a/src/term_main.cc b/src/term_main.cc @@ -52,6 +52,10 @@ draw_source(RuntimeProcess &conn) erase(); conn.read_executions(); + int tus_with_execs = 0; + for (auto &t : conn.m_tus) + tus_with_execs += t.has_execs; + auto &t = conn.m_tus[tu]; total_executions = 0; for (int i = offset; i < (size_y - 2 + offset) && i < t.num_lines; i++) { @@ -95,9 +99,9 @@ draw_source(RuntimeProcess &conn) move(size_y - 1, 0); clrtoeol(); - printw("%s [%s (%i/%i)] [%i fps] [%ik execs/s] [%i us]", - conn.m_progname.c_str(), t.file_name.c_str(), - tu + 1, conn.m_num_tus, fps, eps / 1000, + printw("%s [%s (%i/%i)] [%i fps] [%ik execs/s (%i)] [%i us]", + conn.m_progname.c_str(), "", //t.file_name.c_str(), + tu + 1, conn.m_num_tus, fps, eps / 1000, tus_with_execs, sleep.tv_sec + sleep.tv_nsec / 1000); for (int i = 1; i <= 5; i++) { attron(COLOR_PAIR(i)); @@ -137,11 +141,11 @@ draw_source(RuntimeProcess &conn) struct timespec one = { 1, 0 }; struct timespec zero = { 0, 0 }; - struct timespec shift = { 0, 100 * 1000 }; + struct timespec shift = { 0, 50 * 1000 }; if (timespeccmp(&floating_avg, &one, <)) // We're executing too fast. Increase sleep. timespecadd(&sleep, &shift, &sleep); - else if (timespeccmp(&floating_avg, &one, !=) && timespeccmp(&sleep, &shift, >)) + else if (timespeccmp(&floating_avg, &one, !=) && timespeccmp(&sleep, &shift, >=)) // Floating avg is > 1.0 but we can still subtract at // least shift. timespecsub(&sleep, &shift, &sleep);