-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add pretty bars for compile output #5929
Conversation
Returns: string containing nice looking bars | ||
""" | ||
|
||
# TODO add tty detection, and width detection probably |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a TODO you wanted to address before merging or is it fine as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either or. You can see the current width detection below, which will only work on Linux (but doesn't hurt other OSs):
Lines 628 to 638 in a4bfd01
# TODO add tty detection, and width detection probably | |
WIDTH = 72 | |
try: | |
# NOTE this only works on linux | |
import sys, fcntl, termios, struct | |
height, width, _, _ = struct.unpack('HHHH', | |
fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, | |
struct.pack('HHHH', 0, 0, 0, 0))) | |
WIDTH = min(width, WIDTH) | |
except: | |
pass |
I'm not planning on adding support for other OSs at this time, though I don't think that should stop this PR, they're just stuck at a 72 character width. I did search briefly, but unfortunately finding cross-platform screen width is a nightmare in python 2.7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
I like it! Sorry if I misundertood, but is there a compile flag to allow a user to specify which format they'd like (table versus graph)? Looks like the table print was removed completely. |
Updated 👍 I repurposed --stats-depth to revert back to pretty table printing. So no --stats-depth = pretty bars. |
this might be out of scope but there are unicode characters for doing progress bars at different subdivisions of one character, |
Looks neat 👍 This is using cmsis packs - what happens if device is not yet in the index ? From the code looks like it would fail? As I recall they are used for bootloader or exporters, with this change would be also for compilation. In case of exporter, if device is not yet in the packs, it fails for uvision to export. What is the case for compilation with this patch? |
@drewcassidy, Oh that's a good idea. Although it would look bad on non-unicode terminals. Do you know if there's a way to detect unicode support from a terminal? Do you think we can rely on @0xc0170, good point, I'll wrap all of this in a try catch based on cmsis-pack availability. |
|
@0xc0170, updated, @theotherjimmy suggested I can rely on the presence of Here's the output without a cmsis-pack, though I'm open to suggestions if we want to see something different:
|
@drewcassidy, I think the unicode printing is a neat idea, but I don't think I'm going to be able to implement it at the moment. Feel free to add it in or include it when you add unicode support to the pretty tables. |
@geky Good pick of platform! that one probably won't ever have a CMSIS Pack. That output looks great! I'll review now. |
@theotherjimmy, I just chose the first platform that CI failed on. Speaking of CI failures, apparently the NUCLEO_F767ZI doesn't have any ram? Updated with another catch on cmsis-pack parsing errors. |
memap_table = memap_instance.generate_output('table', stats_depth) | ||
|
||
real_stats_depth = stats_depth if stats_depth is None else 2 | ||
memap_table = memap_instance.generate_output('table', real_stats_depth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you hove these lines into the else statement below? that way we only generate what we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memap_table is also used by the build report below, and the generate_output has side-effects I'm not sure about. You can see it was originally outside of the if not silent
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memap_table is also used by the build report below
That's a good point.
generate_output has side-effects I'm not sure about
It does a compute_report
followed by a reduce_depth
, which will be run by the following generate_output
calls anyway.
tools/memap.py
Outdated
struct.pack('HHHH', 0, 0, 0, 0))) | ||
WIDTH = min(width, WIDTH) | ||
except: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you assign width to 72 here instead? and make that except not catch C-c and similar with
except Exception:
WIDTH = 72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIDTH is also used on line 636 (right above). Will update the second part of your sentence.
tools/memap.py
Outdated
|
||
text = sum(module['size']['.text'] | ||
for module in self.mem_report | ||
if 'size' in module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
text = self.subtotal['.text']
tools/memap.py
Outdated
if 'size' in module) | ||
data = sum(module['size']['.data'] | ||
for module in self.mem_report | ||
if 'size' in module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
data = self.subtotal['.data']
tools/memap.py
Outdated
if 'size' in module) | ||
bss = sum(module['size']['.bss'] | ||
for module in self.mem_report | ||
if 'size' in module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
bss = self.subtotal['.bss']
tools/memap.py
Outdated
bss = sum(module['size']['.bss'] | ||
for module in self.mem_report | ||
if 'size' in module) | ||
rom_used = text + data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
rom_used = self.mem_summary['total_flash']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just add them together? The math below would have problems if they differed
tools/memap.py
Outdated
for module in self.mem_report | ||
if 'size' in module) | ||
rom_used = text + data | ||
ram_used = data + bss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be:
ram_used = self.mem_summary['static_ram']
@geky Who knew? F767ZI has no RAM, huh. |
Looks like this: Building project mbed-os-prettyoutput (ARCH_PRO, GCC_ARM) Scan: . Scan: env Scan: mbed Scan: FEATURE_LWIP Text 70.5KB Data 2.72KB BSS 7.43KB ROM 73.2KB RAM 10.1KB ROM [||||||| ] 73.2KB/512KB RAM [|||||||||||||||| ] 10.1KB/32KB Image: BUILD/ARCH_PRO/GCC_ARM/mbed-os-prettyoutput.bin If you build a target without a cmsis-pack it looks like this: Building project mbed-os-prettyoutput (ARM_BEETLE_SOC, GCC_ARM) Scan: . Scan: env Scan: mbed Scan: FEATURE_BLE Text 99KB Data 2.84KB BSS 13KB ROM 102KB RAM 15.8KB Image: BUILD/ARM_BEETLE_SOC/GCC_ARM/mbed-os-prettyoutput.bin And the old behaviour of displaying the memap table can be brought back by passing the --stats-depth parameter
/morph build |
Build : SUCCESSBuild number : 979 Triggering tests/morph test |
uVisor tests are experiencing an anomaly. @0xc0170 has ping'd the team to determine how to resolve. |
Exporter Build : FAILUREBuild number : 671 |
Test : SUCCESSBuild number : 804 |
/morph uvisor-test |
Exporter Build : SUCCESSBuild number : 679 |
Looks like this:
This is an alternative to the pretty table output that provides useful information about memory consumption without using as much screen real-estate as the pretty table output. You may also note this matches what is displayed on the website, which is an added plus.
cc @theotherjimmy, @0xc0170