Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in reporting stats from spead2_recv #171

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/spead2/tools/recv_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ async def run_stream(stream, name, args):
except (spead2.Stopped, asyncio.CancelledError):
print(f"Shutting down stream {name} after {num_heaps} heaps")
stats = stream.stats
for key in dir(stats):
if not key.startswith('_'):
print("{}: {}".format(key, getattr(stats, key)))
for key, value in stats.items():
print("{}: {}".format(key, getattr(stats, key)))
break
finally:
stream.stop()
Expand Down
17 changes: 4 additions & 13 deletions src/spead2_recv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void show_heap(const spead2::recv::heap &fheap, const options &opts)
{
std::cout
<< "Descriptor for " << descriptor.name
<< " (" << std::hex << descriptor.id << ")\n"
<< " (" << std::hex << descriptor.id << std::dec << ")\n"
<< " description: " << descriptor.description << '\n'
<< " format: [";
bool first = true;
Expand Down Expand Up @@ -168,7 +168,7 @@ static void show_heap(const spead2::recv::heap &fheap, const options &opts)
std::cout << std::hex << item.id << std::dec
<< " = [" << item.length << " bytes]";
if (item.is_immediate)
std::cout << " = " << std::hex << item.immediate_value;
std::cout << " = " << std::hex << item.immediate_value << std::dec;
std::cout << '\n';
}
std::cout << std::noshowbase;
Expand Down Expand Up @@ -391,16 +391,7 @@ int main(int argc, const char **argv)
}

std::cout << "Received " << n_complete << " heaps\n";
#define REPORT_STAT(field) (std::cout << #field ": " << stats.field << '\n')
REPORT_STAT(heaps);
REPORT_STAT(incomplete_heaps_evicted);
REPORT_STAT(incomplete_heaps_flushed);
REPORT_STAT(packets);
REPORT_STAT(batches);
REPORT_STAT(worker_blocked);
REPORT_STAT(max_batch);
REPORT_STAT(single_packet_heaps);
REPORT_STAT(search_dist);
#undef REPORT_STAT
for (const auto field : stats)
std::cout << field.first << ": " << field.second << '\n';
return 0;
}